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

Go to the SVN repository for this file.

1 #ifndef DATATOOL_EXCEPTIONS_HPP
2 #define DATATOOL_EXCEPTIONS_HPP
3 
4 /* $Id: exceptions.hpp 84663 2018-11-27 18:22:00Z ucko $
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: Eugene Vasilchenko
30 *
31 * File Description:
32 * datatool exceptions
33 *
34 */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbiexpt.hpp>
38 #include <stdexcept>
39 #include <list>
40 
42 
43 class CDataType;
44 
45 /////////////////////////////////////////////////////////////////////////////
46 // CDatatoolException - datatool exceptions
47 
48 
50 {
51 public:
52  enum EErrCode {
58  };
59  virtual const char* GetErrCodeString(void) const override
60  {
61  switch (GetErrCode()) {
62  case eNotImplemented: return "eNotImplemented";
63  case eWrongInput: return "eWrongInput";
64  case eInvalidData: return "eInvalidData";
65  case eIllegalCall: return "eIllegalCall";
66  case eForbidden: return "eForbidden";
67  default: return CException::GetErrCodeString();
68  }
69  }
71 };
72 
74 {
75 public:
76  enum EErrCode {
79  eModule
80  };
81  virtual const char* GetErrCodeString(void) const override
82  {
83  switch (GetErrCode()) {
84  case eType: return "eType";
85  case eModule: return "eModule";
86  default: return CException::GetErrCodeString();
87  }
88  }
90 };
91 
93 {
94 public:
95  enum EErrCode {
97  };
98  virtual const char* GetErrCodeString(void) const override
99  {
100  switch (GetErrCode()) {
101  case eAmbiguious: return "eAmbiguious";
102  default: return CException::GetErrCodeString();
103  }
104  }
105 
107  const CException* prev_exception,
108  EErrCode err_code, const string& message,
109  const list<CDataType*>& types,
110  EDiagSev severity = eDiag_Error) THROWS_NONE
111  : CNotFoundException(info, prev_exception, CNotFoundException::eInvalid, message),
112  m_Types(types)
114 
115 public:
116  const list<CDataType*>& GetTypes(void) const THROWS_NONE
117  {
118  return m_Types;
119  }
120 
121 private:
122  list<CDataType*> m_Types;
123 };
124 
126 {
127 public:
128  CResolvedTypeSet(const string& name);
129  CResolvedTypeSet(const string& module, const string& name);
130  ~CResolvedTypeSet(void);
131 
132  void Add(CDataType* type);
133  void Add(const CAmbiguiousTypes& types);
134 
135  CDataType* GetType(void) const THROWS((CDatatoolException));
136 
137 private:
138  string m_Module, m_Name;
139  list<CDataType*> m_Types;
140 };
141 
143 
144 #endif
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
Definition: exceptions.hpp:98
const list< CDataType * > & GetTypes(void) const THROWS_NONE
Definition: exceptions.hpp:116
list< CDataType * > m_Types
Definition: exceptions.hpp:122
NCBI_EXCEPTION_DEFAULT(CDatatoolException, CException)
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
Definition: exceptions.hpp:59
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
Definition: exceptions.hpp:81
NCBI_EXCEPTION_DEFAULT(CNotFoundException, CDatatoolException)
CDataType * GetType(void) const THROWS((CDatatoolException))
Definition: exceptions.cpp:66
void Add(CDataType *type)
Definition: exceptions.cpp:54
list< CDataType * > m_Types
Definition: exceptions.hpp:139
~CResolvedTypeSet(void)
Definition: exceptions.cpp:50
CResolvedTypeSet(const string &name)
Definition: exceptions.cpp:40
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const struct type types[]
Definition: type.c:22
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
#define THROWS_NONE
Do not use 'throw' dynamic exception specification for C++11 compilers.
Definition: ncbiexpt.hpp:74
#define THROWS(x)
Definition: ncbiexpt.hpp:75
EErrCode
Error types that an application can generate.
Definition: ncbiexpt.hpp:884
#define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION(exception_class, base_class)
Helper macro for default exception implementation.
Definition: ncbiexpt.hpp:1300
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
@ eInvalid
To be used ONLY as a return value; please, NEVER throw an exception with this code.
Definition: ncbiexpt.hpp:885
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static MDB_envinfo info
Definition: mdb_load.c:37
Defines NCBI C++ exception handling.
Definition: type.c:6
Modified on Sun Jul 14 04:54:50 2024 by modify_doxy.py rev. 669887