NCBI C++ ToolKit
objmgr_exception.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef OBJMGR_EXCEPTION__HPP
2 #define OBJMGR_EXCEPTION__HPP
3 
4 /* $Id: objmgr_exception.hpp 98733 2022-12-28 15:46:44Z vasilche $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aleksey Grichenko
30 *
31 * File Description:
32 * Object manager exceptions
33 *
34 */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbiexpt.hpp>
38 
41 
42 
43 /** @addtogroup ObjectManagerCore
44  *
45  * @{
46  */
47 
48 
49 /// Base class for all object manager exceptions
51 {
52 public:
53  enum EErrCode {
54  eNotImplemented, ///< The method is not implemented
55  eRegisterError, ///< Error while registering a data source/loader
56  eFindConflict, ///< Conflicting data found
57  eFindFailed, ///< The data requested can not be found
58  eAddDataError, ///< Error while adding new data
59  eModifyDataError, ///< Error while modifying data
60  eInvalidHandle, ///< Attempt to use an invalid handle
61  eLockedData, ///< Attempt to remove locked data
62  eTransaction, ///< Transaction violation
63  eMissingData, ///< The sequence doesn't have the data requested
64  eOtherError
65  };
66  virtual const char* GetErrCodeString(void) const override;
68 };
69 
70 
71 /// SeqMap related exceptions
73 {
74 public:
75  enum EErrCode {
76  eUnimplemented, ///< The method is not implemented
77  eIteratorTooBig, ///< Bad internal iterator in delta map
78  eSegmentTypeError, ///< Wrong segment type
79  eDataError, ///< SeqMap data error
80  eOutOfRange, ///< Iterator is out of range
81  eInvalidIndex, ///< Invalid segment index
82  eNullPointer, ///< Attempt to access non-existing object
83  eSelfReference, ///< Self-reference in seq map is detected
84  eFail ///< Operation failed
85  };
86  virtual const char* GetErrCodeString(void) const override;
88 };
89 
90 
91 /// SeqVector related exceptions
93 {
94 public:
95  enum EErrCode {
96  eCodingError, ///< Incompatible coding selected
97  eDataError, ///< Sequence data error
98  eOutOfRange ///< Attempt to access out-of-range iterator
99  };
100  virtual const char* GetErrCodeString(void) const override;
102 };
103 
104 
105 /// Annotation iterators exceptions
107 {
108 public:
109  enum EErrCode {
110  eBadLocation, ///< Wrong location type while mapping annotations
111  eFindFailed, ///< Seq-id can not be resolved
112  eLimitError, ///< Invalid or unknown limit object
113  eIncomatibleType, ///< Incompatible annotation type (feat/graph/align)
114  eOtherError
115  };
116  virtual const char* GetErrCodeString(void) const override;
118 };
119 
120 
121 /// Data loader exceptions, used by GenBank loader.
123 {
124 public:
125  enum EErrCode {
136  eNotFound
137  };
138  virtual const char* GetErrCodeString(void) const override;
140 public:
141 
142  void SetFailedCall(const string& call);
143 
144 protected:
145  /// Report "non-standard" attributes.
146  virtual void ReportExtra(ostream& out) const override;
147 
148 private:
149  string m_FailedCall;
150 };
151 
152 
153 /// Blob state exceptions, used by GenBank loader.
155 {
156 public:
157  enum EErrCode {
160  eOtherError
161  };
162  typedef int TBlobState;
163 
164  virtual const char* GetErrCodeString(void) const override;
166  const CException* prev_exception,
167  EErrCode err_code,
168  const string& message,
170  EDiagSev severity = eDiag_Error)
171  : CObjMgrException(info, prev_exception,
172  message, severity, 0),
173  m_BlobState(state)
174  {
175  x_Init(info, message, prev_exception, severity);
177  }
179  : CObjMgrException(other),
180  m_BlobState(other.m_BlobState)
181  {
182  x_Assign(other);
183  }
184  virtual ~CBlobStateException(void) noexcept {}
185  const char* GetType(void) const override { return "CBlobStateException"; }
186  typedef int TErrCode;
187  TErrCode GetErrCode(void) const
188  {
189  return typeid(*this) == typeid(CBlobStateException) ?
191  }
193  {
194  return m_BlobState;
195  }
196 
197 protected:
199  virtual const CException* x_Clone(void) const override
200  {
201  return new CBlobStateException(*this);
202  }
203 private:
205 };
206 
207 
208 /// Exceptions for objmgr/util library.
210 {
211 public:
212  enum EErrCode {
220  eBadAlignment
221  };
222  virtual const char* GetErrCodeString(void) const override;
224 };
225 
226 
227 /////////////////////////////////////////////////////////////////////////////
228 // CAnnotSearchLimitException::
229 //
230 // Exception used to notify that some annot iterator search limit
231 // is reached, aborting subsequent search.
232 //
233 
235 {
236 public:
237  enum EErrCode {
238  eTimeLimitExceded = CObjMgrException::eOtherError + 1,
239  eSegmentsLimitExceded
240  };
241 
242  virtual const char* GetErrCodeString(void) const override;
244 };
245 
246 
247 /* @} */
248 
249 
252 
253 #endif // OBJMGR_EXCEPTION__HPP
Annotation iterators exceptions.
Blob state exceptions, used by GenBank loader.
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
Data loader exceptions, used by GenBank loader.
Base class for all object manager exceptions.
Exceptions for objmgr/util library.
SeqMap related exceptions.
SeqVector related exceptions.
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
virtual void ReportExtra(ostream &out) const
Report "non-standard" attributes.
Definition: ncbiexpt.cpp:428
virtual int x_GetErrCode(void) const
Helper method for getting error code.
Definition: ncbiexpt.hpp:1105
virtual void x_Init(const CDiagCompileInfo &info, const string &message, const CException *prev_exception, EDiagSev severity)
Helper method for initializing exception data.
Definition: ncbiexpt.cpp:509
virtual void x_InitErrCode(CException::EErrCode err_code)
Helper method for initializing error code.
Definition: ncbiexpt.cpp:567
virtual void x_Assign(const CException &src)
Helper method for copying exception data.
Definition: ncbiexpt.cpp:536
int TErrCode
Definition: ncbiexpt.hpp:889
EErrCode
Error types that an application can generate.
Definition: ncbiexpt.hpp:884
@ eInvalid
To be used ONLY as a return value; please, NEVER throw an exception with this code.
Definition: ncbiexpt.hpp:885
const char * GetType(void) const override
Get class name as a string.
NCBI_EXCEPTION_DEFAULT(CAnnotSearchLimitException, CObjMgrException)
NCBI_EXCEPTION_DEFAULT(CSeqMapException, CObjMgrException)
TBlobState GetBlobState(void)
NCBI_EXCEPTION_DEFAULT(CObjMgrException, CException)
TErrCode GetErrCode(void) const
NCBI_EXCEPTION_DEFAULT(CObjmgrUtilException, CObjMgrException)
CBlobStateException(const CBlobStateException &other)
virtual const CException * x_Clone(void) const override
Helper method for cloning the exception.
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
virtual ~CBlobStateException(void) noexcept
NCBI_EXCEPTION_DEFAULT(CLoaderException, CObjMgrException)
NCBI_EXCEPTION_DEFAULT(CSeqVectorException, CObjMgrException)
CBlobStateException(const CDiagCompileInfo &info, const CException *prev_exception, EErrCode err_code, const string &message, TBlobState state, EDiagSev severity=eDiag_Error)
NCBI_EXCEPTION_DEFAULT(CAnnotException, CObjMgrException)
@ eDataError
Sequence data error.
@ eCodingError
Incompatible coding selected.
@ eIncomatibleType
Incompatible annotation type (feat/graph/align)
@ eFindFailed
Seq-id can not be resolved.
@ eLimitError
Invalid or unknown limit object.
@ eBadLocation
Wrong location type while mapping annotations.
@ eUnimplemented
The method is not implemented.
@ eSegmentTypeError
Wrong segment type.
@ eIteratorTooBig
Bad internal iterator in delta map.
@ eInvalidIndex
Invalid segment index.
@ eSelfReference
Self-reference in seq map is detected.
@ eNullPointer
Attempt to access non-existing object.
@ eOutOfRange
Iterator is out of range.
@ eDataError
SeqMap data error.
@ eModifyDataError
Error while modifying data.
@ eFindConflict
Conflicting data found.
@ eRegisterError
Error while registering a data source/loader.
@ eNotImplemented
The method is not implemented.
@ eAddDataError
Error while adding new data.
@ eMissingData
The sequence doesn't have the data requested.
@ eLockedData
Attempt to remove locked data.
@ eInvalidHandle
Attempt to use an invalid handle.
@ eTransaction
Transaction violation.
@ eFindFailed
The data requested can not be found.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
static MDB_envinfo info
Definition: mdb_load.c:37
Defines NCBI C++ exception handling.
@ eNotFound
Not found.
Modified on Wed Sep 04 15:03:17 2024 by modify_doxy.py rev. 669887