1 /*  $Id: line_error.hpp 632526 2021-06-02 17:25:01Z ivanov $
2  * ===========================================================================
3  *
4  *                            PUBLIC DOMAIN NOTICE
5  *               National Center for Biotechnology Information
6  *
7  *  This software/database is a "United States Government Work" under the
8  *  terms of the United States Copyright Act.  It was written as part of
9  *  the author's official duties as a United States Government employee and
10  *  thus cannot be copyrighted.  This software/database is freely available
11  *  to the public for use. The National Library of Medicine and the U.S.
12  *  Government have not placed any restriction on its use or reproduction.
13  *
14  *  Although all reasonable efforts have been taken to ensure the accuracy
15  *  and reliability of the software and data, the NLM and the U.S.
16  *  Government do not and cannot warrant the performance or results that
17  *  may be obtained by using this software or data. The NLM and the U.S.
18  *  Government disclaim all warranties, express or implied, including
19  *  warranties of performance, merchantability or fitness for any particular
20  *  purpose.
21  *
22  *  Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Frank Ludwig
27  *
28  * File Description:
29  *   Basic reader interface
30  *
31  */
32 
33 #ifndef OBJTOOLS_READERS___LINEERROR__HPP
34 #define OBJTOOLS_READERS___LINEERROR__HPP
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbimisc.hpp>
38 #include <corelib/ncbiobj.hpp>
39 //#include <corelib/ncbi_message.hpp>
40 #include<objtools/logging/message.hpp>
41 #include <objtools/readers/reader_exception.hpp>
42 
43 
44 BEGIN_NCBI_SCOPE
45 
46 BEGIN_SCOPE(objects) // namespace ncbi::objects::
47 
48 //  ============================================================================
49 class NCBI_XOBJUTIL_EXPORT ILineError : public IObjtoolsMessage
50 //  ============================================================================
51 {
52 public:
53     // If you add to here, make sure to add to ProblemStr()
54     enum EProblem {
55         // useful when you have a problem variable, but haven't found a problem yet
56         eProblem_Unset = 1,
57 
58         eProblem_UnrecognizedFeatureName,
59         eProblem_UnrecognizedQualifierName,
60         eProblem_NumericQualifierValueHasExtraTrailingCharacters,
61         eProblem_NumericQualifierValueIsNotANumber,
62         eProblem_FeatureNameNotAllowed,
63         eProblem_NoFeatureProvidedOnIntervals,
64         eProblem_QualifierWithoutFeature,
65         eProblem_IncompleteFeature,
66         eProblem_FeatureBadStartAndOrStop,
67         eProblem_BadFeatureInterval,
68         eProblem_QualifierBadValue,
69         eProblem_BadScoreValue,
70         eProblem_MissingContext,
71         eProblem_BadTrackLine,
72         eProblem_InternalPartialsInFeatLocation,
73         eProblem_FeatMustBeInXrefdGene,
74         eProblem_CreatedGeneFromMultipleFeats,
75         eProblem_UnrecognizedSquareBracketCommand,
76         eProblem_TooLong,
77         eProblem_UnexpectedNucResidues,
78         eProblem_UnexpectedAminoAcids,
79         eProblem_TooManyAmbiguousResidues,
80         eProblem_InvalidResidue,
81         eProblem_ModifierFoundButNoneExpected,
82         eProblem_ExtraModifierFound,
83         eProblem_ExpectedModifierMissing,
84         eProblem_Missing,
85         eProblem_NonPositiveLength,
86         eProblem_ParsingModifiers,
87         eProblem_ContradictoryModifiers,
88         eProblem_InvalidLengthAutoCorrected, // covers more general cases than eProblem_NonPositiveLength
89         eProblem_IgnoredResidue,
90         eProblem_DiscouragedFeatureName,
91         eProblem_DiscouragedQualifierName,
92         eProblem_InvalidQualifier,
93         eProblem_InconsistentQualifiers, // qualifiers should match across features, but don't
94         eProblem_DuplicateIDs,
95 
96         //vcf specific
97         eProblem_BadInfoLine,
98         eProblem_BadFormatLine,
99         eProblem_BadFilterLine,
100 
101         // not a problem, actually, but used as
102         // the default if PutProgress is
103         // not overridden.
104         eProblem_ProgressInfo,
105 
106         eProblem_GeneralParsingError
107     };
108 
109     /// This is here because the copy constructor may be protected
110     /// eventually.
Clone(void) const111     virtual ILineError *Clone(void) const {
112         /// throw instead of making it pure virtual for backward
113         /// compatibility.
114         NCBI_USER_THROW("not implemented: ILineError::Clone");
115     }
116 
~ILineError(void)117     virtual ~ILineError(void) throw() {}
118 
119     virtual EProblem
120     Problem(void) const = 0;
121 
122     virtual const std::string &
123     SeqId(void) const = 0;
124 
125     virtual unsigned int
126     Line(void) const =0;
127 
128     typedef vector<unsigned int> TVecOfLines;
129     virtual const TVecOfLines &
130     OtherLines(void) const = 0;
131 
132     virtual const std::string &
133     FeatureName(void) const = 0;
134 
135     virtual const std::string &
136     QualifierName(void) const = 0;
137 
138     virtual const std::string &
139     QualifierValue(void) const = 0;
140 
141     // combines the other fields to print a reasonable error message
142     virtual std::string
Message(void) const143     Message(void) const
144     {
145         CNcbiOstrstream result;
146         result << "On SeqId '" << SeqId() << "', line " << Line() << ", severity " << SeverityStr() << ": '"
147                << ProblemStr() << "'";
148         if( ! FeatureName().empty() ) {
149             result << ", with feature name '" << FeatureName() << "'";
150         }
151         if( ! QualifierName().empty() ) {
152             result << ", with qualifier name '" << QualifierName() << "'";
153         }
154         if( ! QualifierValue().empty() ) {
155             result << ", with qualifier value '" << QualifierValue() << "'";
156         }
157         if( ! OtherLines().empty() ) {
158             result << ", with other possibly relevant line(s):";
159             ITERATE( TVecOfLines, line_it, OtherLines() ) {
160                 result << ' ' << *line_it;
161             }
162         }
163         return (string)CNcbiOstrstreamToString(result);
164     }
165 
166 
167     std::string
SeverityStr(void) const168     SeverityStr(void) const
169     {
170         return CNcbiDiag::SeverityName(Severity());
171     };
172 
173     virtual const std::string&
ErrorMessage(void) const174     ErrorMessage(void) const {
175         static string empty("");
176         return empty;
177     }
178 
179     virtual std::string
ProblemStr(void) const180     ProblemStr(void) const
181     {
182         return ProblemStr(Problem());
183     }
184 
185     static
186     std::string
ProblemStr(EProblem eProblem)187     ProblemStr(EProblem eProblem)
188     {
189         switch(eProblem) {
190         case eProblem_Unset:
191             return "Unset";
192         case eProblem_UnrecognizedFeatureName:
193             return "Unrecognized feature name";
194         case eProblem_UnrecognizedQualifierName:
195             return "Unrecognized qualifier name";
196         case eProblem_NumericQualifierValueHasExtraTrailingCharacters:
197             return "Numeric qualifier value has extra trailing characters after the number";
198         case eProblem_NumericQualifierValueIsNotANumber:
199             return "Numeric qualifier value should be a number";
200         case eProblem_FeatureNameNotAllowed:
201             return "Feature name not allowed";
202         case eProblem_NoFeatureProvidedOnIntervals:
203             return "No feature provided on intervals";
204         case eProblem_QualifierWithoutFeature:
205             return "No feature provided for qualifiers";
206         case eProblem_FeatureBadStartAndOrStop:
207             return "Feature bad start and/or stop";
208         case eProblem_GeneralParsingError:
209             return "General parsing error";
210         case eProblem_BadFeatureInterval:
211             return "Bad feature interval";
212         case eProblem_QualifierBadValue:
213             return "Qualifier had bad value";
214         case eProblem_BadScoreValue:
215             return "Invalid score value";
216         case eProblem_MissingContext:
217             return "Value ignored due to missing context";
218         case eProblem_BadTrackLine:
219             return "Bad track line: Expected \"track key1=value1 key2=value2 ...\"";
220         case eProblem_InternalPartialsInFeatLocation:
221             return "Feature's location has internal partials";
222         case eProblem_FeatMustBeInXrefdGene:
223             return "Feature has xref to a gene, but that gene does NOT contain the feature.";
224         case eProblem_CreatedGeneFromMultipleFeats:
225             return "Feature is trying to create a gene that conflicts with the gene created by another feature.";
226         case eProblem_UnrecognizedSquareBracketCommand:
227             return "Unrecognized square bracket command";
228         case eProblem_TooLong:
229             return "Feature is too long";
230         case eProblem_UnexpectedNucResidues:
231             return "Nucleotide residues unexpectedly found in feature";
232         case eProblem_UnexpectedAminoAcids:
233             return "Amino acid residues unexpectedly found in feature";
234         case eProblem_TooManyAmbiguousResidues:
235             return "Too many ambiguous residues";
236         case eProblem_InvalidResidue:
237             return "Invalid residue(s)";
238         case eProblem_ModifierFoundButNoneExpected:
239             return "Modifiers were found where none were expected";
240         case eProblem_ExtraModifierFound:
241             return "Extraneous modifiers found";
242         case eProblem_ExpectedModifierMissing:
243             return "Expected modifier missing";
244         case eProblem_Missing:
245             return "Feature is missing";
246         case eProblem_NonPositiveLength:
247             return "Feature's length must be greater than zero.";
248         case eProblem_ParsingModifiers:
249             return "Could not parse modifiers.";
250         case eProblem_ContradictoryModifiers:
251             return "Multiple different values for modifier";
252         case eProblem_InvalidLengthAutoCorrected:
253             return "Feature had invalid length, but this was automatically corrected.";
254         case eProblem_IgnoredResidue:
255             return "An invalid residue has been ignored";
256         case eProblem_InvalidQualifier:
257             return "Invalid qualifier for feature";
258 
259         case eProblem_BadInfoLine:
260             return "Broken ##INFO line";
261         case eProblem_BadFormatLine:
262             return "Broken ##FORMAT line";
263         case eProblem_BadFilterLine:
264             return "Broken ##FILTER line";
265 
266         case eProblem_ProgressInfo:
267             return "Just a progress info message (no error)";
268         default:
269             return "Unknown problem";
270         }
271     }
272 
Write(CNcbiOstream & out) const273     virtual void Write(
274         CNcbiOstream& out ) const
275     {
276 
277         out << "                " << SeverityStr() << ":" << endl;
278         out << "Problem:        " << ProblemStr() << endl;
279         if (GetCode()) {
280             out << "Code:           " << GetCode();
281             if (GetSubCode()) {
282                 out << "." << GetSubCode();
283             }
284             out << endl;
285         }
286         const string & seqid = SeqId();
287         if (!seqid.empty()) {
288             out << "SeqId:          " << seqid << endl;
289         }
290         if (Line()) {
291             out << "Line:           " << Line() << endl;
292         }
293         const string & feature = FeatureName();
294         if (!feature.empty()) {
295             out << "FeatureName:    " << feature << endl;
296         }
297         const string & qualname = QualifierName();
298         if (!qualname.empty()) {
299             out << "QualifierName:  " << qualname << endl;
300         }
301         const string & qualval = QualifierValue();
302         if (!qualval.empty()) {
303             out << "QualifierValue: " << qualval << endl;
304         }
305         const TVecOfLines & vecOfLines = OtherLines();
306         if( ! vecOfLines.empty() ) {
307             out << "OtherLines:";
308             ITERATE(TVecOfLines, line_it, vecOfLines) {
309                 out << ' ' << *line_it;
310             }
311             out << endl;
312         }
313         out << endl;
314     };
315 
316     // dump the XML on one line since some tools assume that
WriteAsXML(CNcbiOstream & out) const317     virtual void WriteAsXML(
318         CNcbiOstream& out ) const
319     {
320         out << "<message severity=\"" << NStr::XmlEncode(SeverityStr()) << "\" "
321             << "problem=\"" << NStr::XmlEncode(ProblemStr()) << "\" ";
322         if (GetCode()) {
323             string code = NStr::IntToString(GetCode());
324             if (GetSubCode()) {
325                 code += "." + NStr::IntToString(GetSubCode());
326             }
327             out << "code=\"" << NStr::XmlEncode(code) << "\" ";
328         }
329         const string & seqid = SeqId();
330         if (!seqid.empty()) {
331             out << "seqid=\"" << NStr::XmlEncode(seqid) << "\" ";
332         }
333         out << "line=\"" << Line() << "\" ";
334         const string & feature = FeatureName();
335         if (!feature.empty()) {
336             out << "feature_name=\"" << NStr::XmlEncode(feature) << "\" ";
337         }
338         const string & qualname = QualifierName();
339         if (!qualname.empty()) {
340             out << "qualifier_name=\"" << NStr::XmlEncode(qualname) << "\" ";
341         }
342         const string & qualval = QualifierValue();
343         if (!qualval.empty()) {
344             out << "qualifier_value=\"" << NStr::XmlEncode(qualval) << "\" ";
345         }
346         out << ">";
347 
348         // child nodes
349         ITERATE(TVecOfLines, line_it, OtherLines()) {
350             out << "<other_line>" << *line_it << "</other_line>";
351         }
352 
353         out << "</message>" << endl;
354     };
355 
356     // IMessage methods - default implementations or wrappers for ILineError
357     // methods (for backward compatibility).
GetText(void) const358     virtual string GetText(void) const { return Message(); }
GetSeverity(void) const359     virtual EDiagSev GetSeverity(void) const { return Severity(); }
GetCode(void) const360     virtual int GetCode(void) const { return 0; }
GetSubCode(void) const361     virtual int GetSubCode(void) const { return 0; }
Dump(CNcbiOstream & out) const362     virtual void Dump(CNcbiOstream& out) const { Write(out); }
Compose(void) const363     virtual std::string Compose(void) const
364     {
365         return Message();
366     }
367 
368     // This is required to disambiguate IMessage::GetSeverity() and
369     // CException::GetSeverity() in CObjReaderLineException
Severity(void) const370     virtual EDiagSev Severity(void) const { return eDiag_Error; }
371 
DumpAsXML(CNcbiOstream & out) const372     virtual void DumpAsXML(CNcbiOstream& out) const { WriteAsXML(out); }
373 };
374 
375 //  ============================================================================
376 class NCBI_XOBJUTIL_EXPORT CLineError:
377 //  ============================================================================
378     public ILineError
379 {
380 public:
381 
382     /// Use this because the constructor is protected.
383     ///
384     /// @returns
385     ///   Caller is responsible for the return value.
386     static CLineError* Create(
387         EProblem eProblem,
388         EDiagSev eSeverity,
389         const std::string& strSeqId,
390         unsigned int uLine,
391         const std::string & strFeatureName = string(""),
392         const std::string & strQualifierName = string(""),
393         const std::string & strQualifierValue = string(""),
394         const std::string & strErrorMessage = string(""),
395         const TVecOfLines & vecOfOtherLines = TVecOfLines() );
396 
397     /// Use this because copy ctor is protected.
398     virtual ILineError *Clone(void) const;
399 
~CLineError(void)400     virtual ~CLineError(void) throw() {}
401 
402     /// copy constructor is protected so please use this function to
403     /// throw the object.
404     NCBI_NORETURN void Throw(void) const;
405 
PatchLineNumber(unsigned int uLine)406     void PatchLineNumber(
407         unsigned int uLine) { m_uLine = uLine; };
408 
PatchErrorMessage(const string & errorMessage)409     void PatchErrorMessage(
410         const string& errorMessage) {
411         m_strErrorMessage = errorMessage;
412     };
413 
414     // "OtherLines" not set in ctor because it's
415     // use should be somewhat rare
AddOtherLine(unsigned int uOtherLine)416     void AddOtherLine(unsigned int uOtherLine) {
417         m_vecOfOtherLines.push_back(uOtherLine);
418     }
419 
420     EProblem
Problem(void) const421     Problem(void) const { return m_eProblem; }
422 
423     virtual EDiagSev
Severity(void) const424     Severity(void) const { return m_eSeverity; }
425 
426     const std::string &
SeqId(void) const427     SeqId(void) const { return m_strSeqId; }
428 
429     unsigned int
Line(void) const430     Line(void) const { return m_uLine; }
431 
432     const TVecOfLines &
OtherLines(void) const433     OtherLines(void) const { return m_vecOfOtherLines; }
434 
435     const std::string &
FeatureName(void) const436     FeatureName(void) const { return m_strFeatureName; }
437 
438     const std::string &
QualifierName(void) const439     QualifierName(void) const { return m_strQualifierName; }
440 
441     const std::string &
QualifierValue(void) const442     QualifierValue(void) const { return m_strQualifierValue; }
443 
444     virtual std::string
ProblemStr(void) const445     ProblemStr(void) const
446     {
447         if (m_eProblem == ILineError::eProblem_GeneralParsingError  &&
448                 !ErrorMessage().empty()) {
449             return ErrorMessage();
450         }
451         return ILineError::ProblemStr(Problem());
452     }
453 
ErrorMessage(void) const454     const std::string &ErrorMessage(void) const { return m_strErrorMessage; }
455 
456 protected:
457 
458     EProblem m_eProblem;
459     EDiagSev m_eSeverity;
460     std::string m_strSeqId;
461     unsigned int m_uLine;
462     std::string m_strFeatureName;
463     std::string m_strQualifierName;
464     std::string m_strQualifierValue;
465     std::string m_strErrorMessage;
466     TVecOfLines m_vecOfOtherLines;
467 
468     /// protected instead of public.  Please use the Create function instead.
469     CLineError(
470         EProblem eProblem,
471         EDiagSev eSeverity,
472         const std::string& strSeqId,
473         unsigned int uLine,
474         const std::string & strFeatureName,
475         const std::string & strQualifierName,
476         const std::string & strQualifierValue,
477         const std::string & strErrorMessage,
478         const TVecOfLines & m_vecOfOtherLine);
479 
480     /// protected instead of public.  Please use the Throw function to throw
481     /// this exception and try to avoid using the copy constructor at all.
482     CLineError(const CLineError & rhs );
483 };
484 
485 
486 //  ============================================================================
487 class NCBI_XOBJUTIL_EXPORT CLineErrorEx:
488 //  ============================================================================
489     public ILineError
490 {
491 public:
492 
493     /// Use this because the constructor is protected.
494     ///
495     /// @returns
496     ///   Caller is responsible for the return value.
497     static CLineErrorEx* Create(
498         EProblem eProblem,
499         EDiagSev eSeverity,
500         int code,
501         int subcode,
502         const std::string& strSeqId,
503         unsigned int uLine,
504         const std::string & strErrorMessage = string(""),
505         const std::string & strFeatureName = string(""),
506         const std::string & strQualifierName = string(""),
507         const std::string & strQualifierValue = string(""),
508         const TVecOfLines & vecOfOtherLines = TVecOfLines() );
509 
510     /// Use this because copy ctor is protected.
511     virtual ILineError *Clone(void) const override;
512 
~CLineErrorEx(void)513     virtual ~CLineErrorEx(void) {}
514 
515     /// copy constructor is protected so please use this function to
516     /// throw the object.
517     NCBI_NORETURN void Throw(void) const;
518 
PatchLineNumber(unsigned int uLine)519     void PatchLineNumber(
520         unsigned int uLine) { m_uLine = uLine; };
521 
522     // "OtherLines" not set in ctor because it's
523     // use should be somewhat rare
AddOtherLine(unsigned int uOtherLine)524     void AddOtherLine(unsigned int uOtherLine) {
525         m_vecOfOtherLines.push_back(uOtherLine);
526     }
527 
528     EProblem
Problem(void) const529     Problem(void) const override { return m_eProblem; }
530 
531     virtual EDiagSev
Severity(void) const532     Severity(void) const override { return m_eSeverity; }
533 
534     const std::string &
SeqId(void) const535     SeqId(void) const override { return m_strSeqId; }
536 
537     unsigned int
Line(void) const538     Line(void) const override { return m_uLine; }
539 
540     const TVecOfLines &
OtherLines(void) const541     OtherLines(void) const override { return m_vecOfOtherLines; }
542 
543     const std::string &
FeatureName(void) const544     FeatureName(void) const override { return m_strFeatureName; }
545 
546     const std::string &
QualifierName(void) const547     QualifierName(void) const override { return m_strQualifierName; }
548 
549     const std::string &
QualifierValue(void) const550     QualifierValue(void) const override { return m_strQualifierValue; }
551 
552     virtual std::string
ProblemStr(void) const553     ProblemStr(void) const override
554     {
555         if (m_eProblem == ILineError::eProblem_GeneralParsingError  &&
556                 !ErrorMessage().empty()) {
557             return ErrorMessage();
558         }
559         return ILineError::ProblemStr(Problem());
560     }
561 
ErrorMessage(void) const562     const std::string &ErrorMessage(void) const override { return m_strErrorMessage; }
563 
Message(void) const564     virtual string Message(void) const override
565     {
566         return (m_strErrorMessage.empty() ?
567                 ILineError::Message() :
568                 m_strErrorMessage);
569     }
570 
GetCode(void) const571     virtual int GetCode(void) const override { return m_Code; };
GetSubCode(void) const572     virtual int GetSubCode(void) const override { return m_Subcode; }
573 
574 protected:
575 
576     EProblem m_eProblem;
577     EDiagSev m_eSeverity;
578     int m_Code;
579     int m_Subcode;
580     std::string m_strSeqId;
581     unsigned int m_uLine;
582     std::string m_strFeatureName;
583     std::string m_strQualifierName;
584     std::string m_strQualifierValue;
585     std::string m_strErrorMessage;
586     TVecOfLines m_vecOfOtherLines;
587 
588     /// protected instead of public.  Please use the Create function instead.
589     CLineErrorEx(
590         EProblem eProblem,
591         EDiagSev eSeverity,
592         int code,
593         int subcode,
594         const std::string& strSeqId,
595         unsigned int uLine,
596         const std::string & strErrorMessage,
597         const std::string & strFeatureName,
598         const std::string & strQualifierName,
599         const std::string & strQualifierValue,
600         const TVecOfLines & m_vecOfOtherLine);
601 
602     /// protected instead of public.  Please use the Throw function to throw
603     /// this exception and try to avoid using the copy constructor at all.
604     CLineErrorEx(const CLineErrorEx & rhs);
605 };
606 
607 
608 
609 //  ============================================================================
610 class NCBI_XOBJUTIL_EXPORT CObjReaderLineException
611 //  ============================================================================
612     // must inherit from ILineError first due to the way CObject detects
613     // whether or not it's on the heap.
614     : public ILineError, public CObjReaderParseException
615 {
616 public:
617 
618     using CObjReaderParseException::EErrCode;
619 
620     /// Please use this instead of the constructor because the ctor
621     /// is protected.
622     ///
623     /// @returns
624     ///   Caller is responsible for the return value.
625     static CObjReaderLineException* Create(
626         EDiagSev eSeverity,
627         unsigned int uLine,
628         const std::string &strMessage,
629         EProblem eProblem = eProblem_GeneralParsingError,
630         const std::string& strSeqId = string(""),
631         const std::string & strFeatureName = string(""),
632         const std::string & strQualifierName = string(""),
633         const std::string & strQualifierValue = string(""),
634         CObjReaderLineException::EErrCode eErrCode = eFormat,
635         const TVecOfLines & vecOfOtherLines = TVecOfLines()
636         );
637 
638     /// Use instead of copy constructor, which is protected.
639     virtual ILineError *Clone(void) const;
640 
641     // Copy constructor is protected, so please use
642     /// this function to throw this object.
643     NCBI_NORETURN void Throw(void) const;
644 
~CObjReaderLineException(void)645     ~CObjReaderLineException(void) throw() { }
646 
GetErrCode(void) const647     TErrCode GetErrCode(void) const
648     {
649         return (TErrCode) this->x_GetErrCode();
650     }
651 
Problem(void) const652     EProblem Problem(void) const { return m_eProblem; }
SeqId(void) const653     const std::string &SeqId(void) const { return m_strSeqId; }
Severity(void) const654     EDiagSev Severity(void) const { return CObjReaderParseException::GetSeverity(); }
Line(void) const655     unsigned int Line(void) const { return m_uLineNumber; }
OtherLines(void) const656     const TVecOfLines & OtherLines(void) const { return m_vecOfOtherLines; }
FeatureName(void) const657     const std::string &FeatureName(void) const { return m_strFeatureName; }
QualifierName(void) const658     const std::string &QualifierName(void) const { return m_strQualifierName; }
QualifierValue(void) const659     const std::string &QualifierValue(void) const { return m_strQualifierValue; }
660 
ErrorMessage(void) const661     const std::string &ErrorMessage(void) const { return m_strErrorMessage; }
662 
663     std::string ProblemStr() const;
664 
Message() const665     std::string Message() const { return ( GetMsg().empty() ? ILineError::Message() : GetMsg()); }
666 
667     //
668     //  Cludge alert: The line number may not be known at the time the exception
669     //  is generated. In that case, the exception will be fixed up before being
670     //  rethrown.
671     //
672     void
SetLineNumber(unsigned int uLineNumber)673     SetLineNumber(
674         unsigned int uLineNumber ) { m_uLineNumber = uLineNumber; }
675 
676     // "OtherLines" not set in ctor because it's
677     // use should be somewhat rare
AddOtherLine(unsigned int uOtherLine)678     void AddOtherLine(unsigned int uOtherLine) {
679         m_vecOfOtherLines.push_back(uOtherLine);
680     }
681 
682 protected:
683 
684     EProblem m_eProblem;
685     std::string m_strSeqId;
686     unsigned int m_uLineNumber;
687     std::string m_strFeatureName;
688     std::string m_strQualifierName;
689     std::string m_strQualifierValue;
690     std::string m_strErrorMessage;
691     TVecOfLines m_vecOfOtherLines;
692 
693     /// protected instead of public.  Please use the Create function instead.
694     CObjReaderLineException(
695         EDiagSev eSeverity,
696         unsigned int uLine,
697         const std::string &strMessage,
698         EProblem eProblem = eProblem_GeneralParsingError,
699         const std::string& strSeqId = string(""),
700         const std::string & strFeatureName = string(""),
701         const std::string & strQualifierName = string(""),
702         const std::string & strQualifierValue = string(""),
703         CObjReaderLineException::EErrCode eErrCode = eFormat,
704         const TVecOfLines & vecOfOtherLines = TVecOfLines()
705         );
706 
707     /// Protected, so use Clone or Throw instead.
708     CObjReaderLineException(const CObjReaderLineException & rhs );
709 };
710 
711 
712 END_SCOPE(objects)
713 
714 END_NCBI_SCOPE
715 
716 #endif // OBJTOOLS_READERS___LINEERROR__HPP
717