NCBI C++ ToolKit
|
Search Toolkit Book for CSDB_Exception
Exception class used throughout the API. More...
#include <dbapi/simple/sdbapi.hpp>
Public Types | |
enum | EErrCode { eURLFormat , eClosed , eStarted , eNotInOrder , eInconsistent , eUnsupported , eOutOfBounds , eNotExist , eLowLevel , eWrongParams } |
Public Types inherited from CException | |
enum | EErrCode { eInvalid = -1 , eUnknown = 0 } |
Error types that an application can generate. More... | |
enum | EFlags { fConsole = (1 << 0) } |
Miscellaneous generic hints, flags and attributes. More... | |
typedef int | TErrCode |
typedef int | TFlags |
Public Member Functions | |
virtual const char * | GetErrCodeString (void) const override |
Translate from the error code value to its string representation. More... | |
const CDB_Exception * | GetDBException (void) const |
Returns any underlying DBAPI exception, or else NULL. More... | |
CDB_Exception::TErrCode | GetDBErrCode (void) const |
Returns any underlying DBAPI error code, or else CException::eInvalid. More... | |
const char * | GetDBErrCodeString (void) const |
Returns any underlying DBAPI error code string, or else "eInvalid". More... | |
const string & | GetServerName (void) const |
const string & | GetUserName (void) const |
const string & | GetDatabaseName (void) const |
const string & | GetExtraMsg (void) const |
Returns any additional context (typically, the relevant SQL statement or database operation). More... | |
void | ReportExtra (ostream &os) const override |
Report "non-standard" attributes. More... | |
virtual ERetriable | GetRetriable (void) const override |
Retrieve info about ability to retry an action caused the exception. More... | |
CSDB_Exception (const CDiagCompileInfo &info, const CException *prev_exception, const CExceptionArgs< EErrCode > &args, const CDB_Exception::SMessageInContext &message) | |
Public Member Functions inherited from CException | |
CException (const CDiagCompileInfo &info, const CException *prev_exception, EErrCode err_code, const string &message, EDiagSev severity=eDiag_Error, TFlags flags=0) | |
Constructor. More... | |
CException (const CDiagCompileInfo &info, const CException *prev_exception, const CExceptionArgs< EErrCode > &args, const string &message) | |
CException (const CException &other) | |
Copy constructor. More... | |
void | AddBacklog (const CDiagCompileInfo &info, const string &message, EDiagSev severity=eDiag_Error) |
Add a message to backlog (to re-throw the same exception then). More... | |
void | AddPrevious (const CException *prev_exception) |
void | AddToMessage (const string &add_msg) |
virtual void | Throw (void) const |
Polymorphically (re)throw an exception whose exact type is uncertain. More... | |
virtual const char * | what (void) const noexcept |
Standard report (includes full backlog). More... | |
void | Report (const CDiagCompileInfo &info, const string &title, CExceptionReporter *reporter=0, TDiagPostFlags flags=eDPF_Exception) const |
Report the exception. More... | |
string | ReportThis (TDiagPostFlags flags=eDPF_Exception) const |
Report this exception only. More... | |
string | ReportAll (TDiagPostFlags flags=eDPF_Exception) const |
Report all exceptions. More... | |
void | ReportStd (ostream &out, TDiagPostFlags flags=eDPF_Exception) const |
Report "standard" attributes. More... | |
const CStackTrace * | GetStackTrace (void) const |
Get the saved stack trace if available or NULL. More... | |
EDiagSev | GetSeverity (void) const |
Get exception severity. More... | |
CException & | SetSeverity (EDiagSev severity) |
Set exception severity. More... | |
virtual const char * | GetType (void) const |
Get class name as a string. More... | |
const string & | GetFile (void) const |
Get file name used for reporting. More... | |
void | SetModule (const string &module) |
Set module name used for reporting. More... | |
const string & | GetModule (void) const |
Get module name used for reporting. More... | |
void | SetClass (const string &nclass) |
Set class name used for reporting. More... | |
const string & | GetClass (void) const |
Get class name used for reporting. More... | |
void | SetFunction (const string &function) |
Set function name used for reporting. More... | |
const string & | GetFunction (void) const |
Get function name used for reporting. More... | |
int | GetLine (void) const |
Get line number where error occurred. More... | |
TErrCode | GetErrCode (void) const |
Get error code. More... | |
const string & | GetMsg (void) const |
Get message string. More... | |
const CException * | GetPredecessor (void) const |
Get "previous" exception from the backlog. More... | |
bool | HasMainText (void) const |
Check if exception has main text in the chain. More... | |
virtual | ~CException (void) noexcept |
Destructor. More... | |
bool | IsSetFlag (EFlags flag) const |
Check if the flag is set. More... | |
CException & | SetFlag (EFlags flag) |
Set flag (add to other flags) More... | |
CException & | UnsetFlag (EFlags flag) |
Unset flag (other flags are left as is) More... | |
CRequestContext & | GetRequestContext (void) const |
Get the request context in which the exception was thrown. More... | |
void | SetRetriable (ERetriable retriable) |
Set the info about ability to retry an action caused the exception. More... | |
Protected Member Functions | |
CSDB_Exception (const CDiagCompileInfo &info, const CException *prev_exception, const CDB_Exception::SMessageInContext &message, EDiagSev severity=eDiag_Error, CException::TFlags flags=0) | |
void | x_Init (const CDiagCompileInfo &info, const string &message, const CException *prev_exception, EDiagSev severity) override |
Helper method for initializing exception data. More... | |
void | x_Assign (const CException &src) override |
Helper method for copying exception data. More... | |
Protected Member Functions inherited from CException | |
CException (const CDiagCompileInfo &info, const CException *prev_exception, const string &message, EDiagSev severity=eDiag_Error, TFlags flags=0) | |
Constructor for derived classes. More... | |
CException (void) | |
Constructor with no arguments. More... | |
virtual void | x_ReportToDebugger (void) const |
Helper method for reporting to the system debugger. More... | |
virtual const CException * | x_Clone (void) const |
Helper method for cloning the exception. More... | |
virtual void | x_InitArgs (const CExceptionArgs_Base &args) |
Process additional arguments. More... | |
virtual void | x_AssignErrCode (const CException &src) |
Helper method for assigning error code. More... | |
virtual void | x_InitErrCode (CException::EErrCode err_code) |
Helper method for initializing error code. More... | |
virtual int | x_GetErrCode (void) const |
Helper method for getting error code. More... | |
void | x_GetStackTrace (void) |
Get and store current stack trace. More... | |
void | x_ThrowSanityCheck (const type_info &expected_type, const char *human_name) const |
Warn if Throw() will end up slicing its invocant. More... | |
Private Attributes | |
CConstRef< CDB_Exception::SContext > | m_Context |
Additional Inherited Members | |
Static Public Member Functions inherited from CException | |
static bool | EnableBackgroundReporting (bool enable) |
Enable background reporting. More... | |
static void | SetStackTraceLevel (EDiagSev level) |
Set severity level for saving and printing stack trace. More... | |
static EDiagSev | GetStackTraceLevel (void) |
Get current severity level for saving and printing stack trace. More... | |
Exception class used throughout the API.
Definition at line 67 of file sdbapi.hpp.
Enumerator | |
---|---|
eURLFormat | Incorrectly formated URL is used to create CSDB_ConnectionParam. |
eClosed | CDatabase/CQuery/CBulkInsert is tried to be used when no connection is opened. |
eStarted | CBulkInsert has already started to send data, no changes in meta-information can be made. |
eNotInOrder | Columns cannot be bound to CBulkInsert randomly. |
eInconsistent | Operation logically incorrect is attempted to be made (increase past end() iterator, incorrect number of values in CBulkInsert etc) |
eUnsupported | Unsupported data type conversion is requested. |
eOutOfBounds | Conversion of string to integer type exceeded limits of requested type. |
eNotExist | Field/parameter with given name/position does not exist. |
eLowLevel | Exception from low level DBAPI was re-thrown with this exception class. |
eWrongParams | Wrong parameters provided to the method. |
Definition at line 70 of file sdbapi.hpp.
|
inline |
Definition at line 127 of file sdbapi.hpp.
References CExceptionArgs< TErrCode >::GetErrCode(), CExceptionArgs_Base::GetSeverity(), info, CDB_Exception::SMessageInContext::message, x_Init(), CException::x_InitArgs(), and CException::x_InitErrCode().
|
inlineprotected |
Definition at line 1385 of file sdbapi.hpp.
Definition at line 1428 of file sdbapi.hpp.
References CDB_Exception::SContext::database_name, and m_Context.
|
inline |
Returns any underlying DBAPI error code, or else CException::eInvalid.
Definition at line 1402 of file sdbapi.hpp.
References CException::eInvalid, GetDBException(), and CDB_Exception::Type().
|
inline |
Returns any underlying DBAPI error code string, or else "eInvalid".
Definition at line 1409 of file sdbapi.hpp.
References GetDBException(), and CDB_Exception::GetErrCodeString().
|
inline |
Returns any underlying DBAPI exception, or else NULL.
Definition at line 1396 of file sdbapi.hpp.
References CException::GetPredecessor().
Referenced by GetDBErrCode(), and GetDBErrCodeString().
|
overridevirtual |
Translate from the error code value to its string representation.
Reimplemented from CException.
Definition at line 71 of file sdbapi.cpp.
References eClosed, eInconsistent, eLowLevel, eNotExist, eNotInOrder, eOutOfBounds, eStarted, eUnsupported, eURLFormat, eWrongParams, CException::GetErrCode(), and CException::GetErrCodeString().
Returns any additional context (typically, the relevant SQL statement or database operation).
Definition at line 1434 of file sdbapi.hpp.
References CDB_Exception::SContext::extra_msg, and m_Context.
|
overridevirtual |
Retrieve info about ability to retry an action caused the exception.
Reimplemented from CException.
Definition at line 119 of file sdbapi.cpp.
References eRetriable_Unknown, CException::GetPredecessor(), and CException::GetRetriable().
Definition at line 1416 of file sdbapi.hpp.
References m_Context, and CDB_Exception::SContext::server_name.
Referenced by CDBLBClientApp::x_RunLookup().
Definition at line 1422 of file sdbapi.hpp.
References m_Context, and CDB_Exception::SContext::username.
|
overridevirtual |
Report "non-standard" attributes.
Report "non-standard" attributes (those of derived class) into the "out" stream.
Reimplemented from CException.
Definition at line 90 of file sdbapi.cpp.
References m_Context.
|
overrideprotectedvirtual |
Helper method for copying exception data.
Reimplemented from CException.
Definition at line 111 of file sdbapi.cpp.
References _ASSERT, m_Context, NULL, and CException::x_Assign().
|
overrideprotectedvirtual |
Helper method for initializing exception data.
Reimplemented from CException.
Reimplemented in CSDB_DeadlockException.
Definition at line 95 of file sdbapi.cpp.
References CConstRef< C, Locker >::Empty(), CDB_Exception::GetContext(), kEmptyContext, m_Context, NULL, prev(), CConstRef< C, Locker >::Reset(), and CDB_Exception::SContext::UpdateFrom().
Referenced by CSDB_Exception().
|
private |
Definition at line 153 of file sdbapi.hpp.
Referenced by GetDatabaseName(), GetExtraMsg(), GetServerName(), GetUserName(), ReportExtra(), x_Assign(), and x_Init().