1 /*
2 * $Id: aln_errors.cpp 632526 2021-06-02 17:25:01Z ivanov $
3 *
4 * ===========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * ===========================================================================
27 *
28 * Authors: Colleen Bollin
29 *
30 */
31
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistr.hpp>
34 #include <objtools/readers/reader_error_codes.hpp>
35 #include <objtools/readers/message_listener.hpp>
36 #include <objtools/readers/reader_error_codes.hpp>
37 #include "aln_errors.hpp"
38
39 BEGIN_NCBI_SCOPE
40 BEGIN_SCOPE(objects);
41
42 thread_local unique_ptr<CAlnErrorReporter> theErrorReporter;
43
44 // ----------------------------------------------------------------------------
45 BEGIN_NAMED_ENUM_INFO("", EReaderCode, false)
46 // ----------------------------------------------------------------------------
47 {
48 ADD_ENUM_VALUE("Undefined", eReader_Undefined);
49 ADD_ENUM_VALUE("Mods", eReader_Mods);
50 ADD_ENUM_VALUE("Alignment", eReader_Alignment);
51 }
52 END_ENUM_INFO
53
54
55 // ----------------------------------------------------------------------------
56 BEGIN_NAMED_ENUM_INFO("", EAlnSubcode, false)
57 // ----------------------------------------------------------------------------
58 {
59 ADD_ENUM_VALUE("Undefined", eAlnSubcode_Undefined);
60 ADD_ENUM_VALUE("BadDataChars", eAlnSubcode_BadDataChars);
61 ADD_ENUM_VALUE("UnterminatedCommand", eAlnSubcode_UnterminatedCommand);
62 ADD_ENUM_VALUE("UnterminatedBlock", eAlnSubcode_UnterminatedBlock);
63 ADD_ENUM_VALUE("UnexpectedSeqId", eAlnSubcode_UnexpectedSeqId);
64 ADD_ENUM_VALUE("BadDataCount", eAlnSubcode_BadDataCount);
65 ADD_ENUM_VALUE("BadSequenceCount", eAlnSubcode_BadSequenceCount);
66 ADD_ENUM_VALUE("IllegalDataLine", eAlnSubcode_IllegalDataLine);
67 ADD_ENUM_VALUE("MissingDataLine", eAlnSubcode_MissingDataLine);
68 ADD_ENUM_VALUE("IllegalSequenceId", eAlnSubcode_IllegalSequenceId);
69 ADD_ENUM_VALUE("IllegalDefinitionLine", eAlnSubcode_IllegalDefinitionLine);
70 ADD_ENUM_VALUE("InsufficientDeflineInfo", eAlnSubcode_InsufficientDeflineInfo);
71 ADD_ENUM_VALUE("UnsupportedFileFormat", eAlnSubcode_UnsupportedFileFormat);
72 ADD_ENUM_VALUE("UnterminatedComment", eAlnSubcode_UnterminatedComment);
73 ADD_ENUM_VALUE("UnusedLine", eAlnSubcode_UnusedLine);
74 ADD_ENUM_VALUE("InconsistentMolType", eAlnSubcode_InconsistentMolType);
75 ADD_ENUM_VALUE("IllegalDataDescription", eAlnSubcode_IllegalDataDescription);
76 ADD_ENUM_VALUE("FileDoesNotExist", eAlnSubcode_FileDoesNotExist);
77 ADD_ENUM_VALUE("FileTooShort", eAlnSubcode_FileTooShort);
78 ADD_ENUM_VALUE("UnexpectedCommand", eAlnSubcode_UnexpectedCommand);
79 ADD_ENUM_VALUE("UnexpectedCommandArgs", eAlnSubcode_UnexpectedCommandArgs);
80 }
81 END_ENUM_INFO
82
83
84 // ----------------------------------------------------------------------------
85 BEGIN_NAMED_ENUM_INFO("", EModSubcode, false)
86 // ----------------------------------------------------------------------------
87 {
88 ADD_ENUM_VALUE("Undefined", eModSubcode_Undefined);
89 ADD_ENUM_VALUE("Unrecognized", eModSubcode_Unrecognized);
90 ADD_ENUM_VALUE("InvalidValue", eModSubcode_InvalidValue);
91 ADD_ENUM_VALUE("Duplicate", eModSubcode_Duplicate);
92 ADD_ENUM_VALUE("ConflictingValues", eModSubcode_ConflictingValues);
93 ADD_ENUM_VALUE("Deprecated", eModSubcode_Deprecated);
94 ADD_ENUM_VALUE("ProteinModOnNucseq", eModSubcode_ProteinModOnNucseq);
95 }
96 END_ENUM_INFO
97
98 // ----------------------------------------------------------------------------
ErrorPrintf(const char * format,...)99 string ErrorPrintf(const char *format, ...)
100 // ----------------------------------------------------------------------------
101 {
102 va_list args;
103 va_start(args, format);
104 return NStr::FormatVarargs(format, args);
105 }
106
107 // ----------------------------------------------------------------------------
BadCharCountPrintf(int expectedCount,int actualCount)108 string BadCharCountPrintf(int expectedCount, int actualCount)
109 // ----------------------------------------------------------------------------
110 {
111 return
112 ("Number of characters on sequence line is different from expected. " +
113 ErrorPrintf("Expected number of characters is %d. Actual number of characters is %d.",
114 expectedCount, actualCount));
115 }
116
117 END_SCOPE(objects)
118 END_NCBI_SCOPE
119