61 #if defined(NCBI_USE_THROW_SPEC) && defined(NCBI_HAVE_CXX11)
62 # undef NCBI_USE_THROW_SPEC
70 #ifdef NCBI_USE_THROW_SPEC
71 # define THROWS_NONE nothrow
72 # define THROWS(x) throw x
80 #define ABORT_ON_THROW "ABORT_ON_THROW"
105 const char* msg1,
const char* msg2);
120 # define RETHROW_TRACE \
122 _TRACE("EXCEPTION: re-throw"); \
123 NCBI_NS_NCBI::DoThrowTraceAbort(); \
135 template<
class T,
class = T>
139 is_member_function_pointer<decltype(&T::what)>::
value,
140 T>::
type> : true_type {};
145 template<
class V>
static auto check(
const V&) -> decltype(declval<ostream&>() << declval<V>());
146 template<
typename>
static bool check(...);
147 using type =
typename is_same<bool, decltype(check<T>(declval<T>()))>::
type;
151 template<
class T,
class = T>
159 template<
class T,
class = T>
168 template<
class T,
class = T>
246 # define THROW_TRACE_SIMPLE(exception_object) \
247 throw NCBI_NS_NCBI::DbgPrintEx(DIAG_COMPILE_INFO, \
248 exception_object, #exception_object)
269 # define THROW_TRACE_ARGS(exception_class, ...) \
270 throw NCBI_NS_NCBI::DbgPrintEx(DIAG_COMPILE_INFO, \
271 exception_class(__VA_ARGS__), #exception_class)
285 const T& e,
const char* e_str)
295 const char* e,
const char*)
305 char* e,
const char*)
315 const string& e,
const char*)
364 # define THROW0_TRACE(exception_object) \
365 throw NCBI_NS_NCBI::DbgPrint(DIAG_COMPILE_INFO, \
366 exception_object, #exception_object)
383 # define THROW0p_TRACE(exception_object) \
384 throw NCBI_NS_NCBI::DbgPrintP(DIAG_COMPILE_INFO, \
385 exception_object, #exception_object)
400 # define THROW0np_TRACE(exception_object) \
401 throw NCBI_NS_NCBI::DbgPrintNP(DIAG_COMPILE_INFO, \
402 exception_object, #exception_object)
417 # define THROW1_TRACE(exception_class, exception_arg) \
418 throw NCBI_NS_NCBI::DbgPrint(DIAG_COMPILE_INFO, \
419 exception_class(exception_arg), #exception_class)
436 # define THROW1p_TRACE(exception_class, exception_arg) \
437 throw NCBI_NS_NCBI::DbgPrintP(DIAG_COMPILE_INFO, \
438 exception_class(exception_arg), #exception_class)
453 # define THROW1np_TRACE(exception_class, exception_arg) \
454 throw NCBI_NS_NCBI::DbgPrintNP(DIAG_COMPILE_INFO, \
455 exception_class(exception_arg), #exception_class)
477 # define THROW_TRACE(exception_class, exception_args) \
478 throw NCBI_NS_NCBI::DbgPrint(DIAG_COMPILE_INFO, \
479 exception_class exception_args, #exception_class)
499 # define THROWp_TRACE(exception_class, exception_args) \
500 throw NCBI_NS_NCBI::DbgPrintP(DIAG_COMPILE_INFO, \
501 exception_class exception_args, #exception_class)
519 # define THROWnp_TRACE(exception_class, exception_args) \
520 throw NCBI_NS_NCBI::DbgPrintNP(DIAG_COMPILE_INFO, \
521 exception_class exception_args, #exception_class)
528 # define RETHROW_TRACE \
531 # define THROW_TRACE_SIMPLE(exception_object) \
532 throw exception_object
533 # define THROW_TRACE_ARGS(exception_class, ...) \
534 throw exception_class(__VA_ARGS__)
536 # define THROW0_TRACE(exception_object) \
537 throw exception_object
538 # define THROW0p_TRACE(exception_object) \
539 throw exception_object
540 # define THROW0np_TRACE(exception_object) \
541 throw exception_object
542 # define THROW1_TRACE(exception_class, exception_arg) \
543 throw exception_class(exception_arg)
544 # define THROW1p_TRACE(exception_class, exception_arg) \
545 throw exception_class(exception_arg)
546 # define THROW1np_TRACE(exception_class, exception_arg) \
547 throw exception_class(exception_arg)
548 # define THROW_TRACE(exception_class, exception_args) \
549 throw exception_class exception_args
550 # define THROWp_TRACE(exception_class, exception_args) \
551 throw exception_class exception_args
552 # define THROWnp_TRACE(exception_class, exception_args) \
553 throw exception_class exception_args
560 #define STD_CATCH(message) \
561 catch (NCBI_NS_STD::exception& e) { \
562 NCBI_NS_NCBI::CNcbiDiag() \
563 << NCBI_NS_NCBI::Error \
564 << "[" << message << "] Exception: " << e.what(); \
570 #define STD_CATCH_ALL(message) \
573 NCBI_NS_NCBI::CNcbiDiag() \
574 << NCBI_NS_NCBI::Error \
575 << "[" << message << "] Unknown exception"; \
580 #define NCBI_CATCH(message) \
581 catch (NCBI_NS_NCBI::CException& e) { \
582 NCBI_REPORT_EXCEPTION(message, e); \
587 #define NCBI_CATCH_ALL(message) \
588 catch (NCBI_NS_NCBI::CException& e) { \
589 NCBI_REPORT_EXCEPTION(message, e); \
591 STD_CATCH_ALL(message)
600 #define STD_CATCH_X(err_subcode, message) \
601 STD_CATCH_XX(NCBI_USE_ERRCODE_X, err_subcode, message)
608 #define STD_CATCH_ALL_X(err_subcode, message) \
609 STD_CATCH_ALL_XX(NCBI_USE_ERRCODE_X, err_subcode, message)
615 #define NCBI_CATCH_X(err_subcode, message) \
616 NCBI_CATCH_XX(NCBI_USE_ERRCODE_X, err_subcode, message)
619 #define NCBI_CATCH_ALL_X(err_subcode, message) \
620 NCBI_CATCH_ALL_XX(NCBI_USE_ERRCODE_X, err_subcode, message)
626 #define STD_CATCH_XX(err_name, err_subcode, message) \
627 catch (NCBI_NS_STD::exception& e) { \
628 NCBI_CHECK_ERR_SUBCODE_X_NAME(err_name, err_subcode); \
629 NCBI_NS_NCBI::CNcbiDiag() \
630 << ErrCode(NCBI_ERRCODE_X_NAME(err_name), err_subcode) \
631 << NCBI_NS_NCBI::Error \
632 << "[" << message << "] Exception: " << e.what(); \
640 #define STD_CATCH_ALL_XX(err_name, err_subcode, message) \
641 STD_CATCH_XX(err_name, err_subcode, message) \
643 NCBI_NS_NCBI::CNcbiDiag() \
644 << ErrCode(NCBI_ERRCODE_X_NAME(err_name), err_subcode) \
645 << NCBI_NS_NCBI::Error \
646 << "[" << message << "] Unknown exception"; \
653 #define NCBI_CATCH_XX(err_name, err_subcode, message) \
654 catch (NCBI_NS_NCBI::CException& e) { \
655 NCBI_REPORT_EXCEPTION_XX(err_name, err_subcode, message, e); \
657 STD_CATCH_XX(err_name, err_subcode, message)
660 #define NCBI_CATCH_ALL_XX(err_name, err_subcode, message) \
661 catch (NCBI_NS_NCBI::CException& e) { \
662 NCBI_REPORT_EXCEPTION_XX(err_name, err_subcode, message, e); \
664 STD_CATCH_ALL_XX(err_name, err_subcode, message)
672 #define FORMAT(message) \
673 NCBI_NS_NCBI::CNcbiOstrstreamToString(static_cast<NCBI_NS_NCBI::CNcbiOstrstream&>(NCBI_NS_NCBI::CNcbiOstrstream().flush() << message))
678 #define NCBI_EXCEPTION_VAR_EX(name, prev_exception_ptr, \
679 exception_class, err_code, message) \
680 exception_class name(DIAG_COMPILE_INFO, \
681 prev_exception_ptr, exception_class::err_code, (message))
684 #define NCBI_EXCEPTION_VAR(name, exception_class, err_code, message) \
685 NCBI_EXCEPTION_VAR_EX(name, 0, exception_class, err_code, message)
688 #define NCBI_EXCEPTION_THROW(exception_var) \
689 throw (exception_var)
691 #define NCBI_EXCEPTION_EMPTY_NAME
695 #define NCBI_EXCEPTION(exception_class, err_code, message) \
696 NCBI_EXCEPTION_VAR(NCBI_EXCEPTION_EMPTY_NAME, \
697 exception_class, err_code, message)
704 #define NCBI_THROW(exception_class, err_code, message) \
706 USING_SCOPE(NCBI_NS_NCBI::ncbi_ex_manip); \
707 NCBI_EXCEPTION_THROW(NCBI_EXCEPTION(exception_class, err_code, \
715 #define NCBI_USER_THROW(message) \
716 NCBI_THROW(NCBI_NS_NCBI::CException, eUnknown, message)
719 #define NCBI_THROW_FMT(exception_class, err_code, message) \
720 NCBI_THROW(exception_class, err_code, FORMAT(message))
724 #define NCBI_USER_THROW_FMT(message) \
725 NCBI_THROW_FMT(NCBI_NS_NCBI::CException, eUnknown, message)
729 #define NCBI_EXCEPTION_EX(prev_exception, exception_class, err_code, message) \
730 NCBI_EXCEPTION_VAR_EX(NCBI_EXCEPTION_EMPTY_NAME, &(prev_exception), \
731 exception_class, err_code, message)
737 #define NCBI_RETHROW(prev_exception, exception_class, err_code, message) \
739 USING_SCOPE(NCBI_NS_NCBI::ncbi_ex_manip); \
740 throw NCBI_EXCEPTION_EX(prev_exception, exception_class, \
741 err_code, message); \
745 #define NCBI_RETHROW_FMT(prev_exception, exception_class, err_code, message) \
746 NCBI_RETHROW(prev_exception, exception_class, err_code, FORMAT(message))
749 #define NCBI_RETHROW_SAME(prev_exception, message) \
750 do { prev_exception.AddBacklog(DIAG_COMPILE_INFO, message, \
751 prev_exception.GetSeverity()); \
755 #define NCBI_REPORT_EXCEPTION(title, ex) \
756 NCBI_NS_NCBI::CExceptionReporter::ReportDefault \
757 (DIAG_COMPILE_INFO, title, ex, NCBI_NS_NCBI::eDPF_Default)
761 #define NCBI_REPORT_EXCEPTION_X(err_subcode, title, ex) \
762 NCBI_REPORT_EXCEPTION_XX(NCBI_USE_ERRCODE_X, err_subcode, title, ex)
766 #define NCBI_REPORT_EXCEPTION_XX(err_name, err_subcode, title, ex) \
767 NCBI_CHECK_ERR_SUBCODE_X_NAME(err_name, err_subcode); \
768 NCBI_NS_NCBI::CExceptionReporter::ReportDefaultEx \
769 (NCBI_ERRCODE_X_NAME(err_name), err_subcode, \
770 DIAG_COMPILE_INFO, title, ex, NCBI_NS_NCBI::eDPF_Default)
841 template<
class TErrCode>
910 const string& message,
917 const string& message);
924 const string& message,
927 void AddPrevious(
const CException* prev_exception);
928 void AddToMessage(
const string& add_msg);
941 NCBI_NORETURN
virtual void Throw(
void)
const;
946 virtual const char* what(
void)
const noexcept;
977 virtual void ReportExtra(ostream&
out)
const;
988 static bool EnableBackgroundReporting(
bool enable);
991 static void SetStackTraceLevel(
EDiagSev level);
994 static EDiagSev GetStackTraceLevel(
void);
1005 virtual const char* GetType(
void)
const;
1008 virtual const char* GetErrCodeString(
void)
const;
1011 const string&
GetFile(
void)
const {
return m_File; }
1020 void SetClass(
const string& nclass) { m_Class = nclass; }
1035 TErrCode GetErrCode(
void)
const;
1038 const string& GetMsg(
void)
const;
1071 const string& message,
1080 virtual void x_ReportToDebugger(
void)
const;
1083 virtual const CException* x_Clone(
void)
const;
1087 const string& message,
1099 virtual void x_AssignErrCode(
const CException& src);
1108 void x_GetStackTrace(
void);
1112 const char* human_name)
const;
1152 template<
class TErrCode>
1162 template<
class TErrCode>
1259 template <
class TTo,
class TFrom>
1262 return typeid(from) ==
typeid(TTo) ?
dynamic_cast<const TTo*
>(&from) : 0;
1265 #define NCBI_EXCEPTION_DEFAULT_THROW(exception_class) \
1266 NCBI_NORETURN virtual void Throw(void) const override \
1268 this->x_ThrowSanityCheck(typeid(exception_class), #exception_class); \
1272 #define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_COMMON(exception_class, base_class) \
1273 exception_class(const exception_class& other) \
1274 : base_class(other) \
1276 this->x_Assign(other); \
1279 virtual ~exception_class(void) noexcept {} \
1280 virtual const char* GetType(void) const override {return #exception_class;} \
1281 typedef int TErrCode; \
1282 TErrCode GetErrCode(void) const \
1284 return typeid(*this) == typeid(exception_class) ? \
1285 (TErrCode) this->x_GetErrCode() : \
1286 (TErrCode) CException::eInvalid; \
1288 NCBI_EXCEPTION_DEFAULT_THROW(exception_class) \
1290 exception_class(void) {} \
1291 virtual const CException* x_Clone(void) const override \
1293 return new exception_class(*this); \
1300 #define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION(exception_class, base_class) \
1302 x_Init(info, message, prev_exception, severity); \
1303 x_InitErrCode((CException::EErrCode) err_code); \
1305 NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_COMMON(exception_class, base_class) \
1308 static void xx_unused_##exception_class(void)
1315 #define NCBI_EXCEPTION_DEFAULT(exception_class, base_class) \
1317 exception_class(const CDiagCompileInfo& info, \
1318 const CException* prev_exception, EErrCode err_code, \
1319 const string& message, EDiagSev severity = eDiag_Error) \
1320 : base_class(info, prev_exception, (message), severity, 0) \
1322 x_Init(info, message, prev_exception, severity); \
1323 x_InitErrCode((CException::EErrCode) err_code); \
1325 exception_class(const CDiagCompileInfo& info, \
1326 const CException* prev_exception, \
1327 const CExceptionArgs<EErrCode>& args, \
1328 const string& message) \
1329 : base_class(info, prev_exception, (message), \
1330 args.GetSeverity(), 0) \
1332 x_Init(info, message, prev_exception, args.GetSeverity()); \
1334 x_InitErrCode((CException::EErrCode) args.GetErrCode()); \
1337 exception_class(const CDiagCompileInfo& info, \
1338 const CException* prev_exception, \
1339 const string& message, \
1340 EDiagSev severity, CException::TFlags flags) \
1341 : base_class(info, prev_exception, (message), severity, flags) \
1345 NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_COMMON(exception_class, \
1349 static void xx_unused_##exception_class(void)
1356 #define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_TEMPL(exception_class, base_class) \
1358 this->x_Init(info, message, prev_exception, severity); \
1359 this->x_InitErrCode((typename CException::EErrCode) err_code); \
1361 NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_COMMON(exception_class, base_class)
1365 #define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_TEMPL_ERRNO(exception_class, base_class) \
1367 this->x_Init(info, message, prev_exception, severity); \
1368 this->x_InitErrCode((typename CException::EErrCode) err_code); \
1370 NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_COMMON(exception_class, base_class) \
1372 virtual const char* GetErrCodeString(void) const override \
1374 switch (GetErrCode()) { \
1375 case CParent::eErrno: return "eErrno"; \
1376 default: return CException::GetErrCodeString(); \
1388 #define EXCEPTION_VIRTUAL_BASE
1417 static bool EnableDefault(
bool enable);
1421 const string& title,
const std::exception& ex,
1426 static void ReportDefaultEx(
int err_code,
int err_subcode,
1428 const string& title,
const std::exception& ex,
1458 virtual void Report(
const char*
file,
int line,
1490 virtual const char* GetErrCodeString(
void)
const override;
1513 virtual const char* GetErrCodeString(
void)
const override;
1526 #ifdef NCBI_COMPILER_GCC
1529 # define NCBI_ERRNO_CODE_WRAPPER NCBI_NS_NCBI::NcbiErrnoCode
1530 # define NCBI_ERRNO_STR_WRAPPER NCBI_NS_NCBI::NcbiErrnoStr
1535 static int GetErrCode(
void)
1537 static const char* GetErrCodeString(
int errnum)
1542 # define NCBI_ERRNO_CODE_WRAPPER NCBI_NS_NCBI::CErrnoAdapt::GetErrCode
1543 # define NCBI_ERRNO_STR_WRAPPER NCBI_NS_NCBI::CErrnoAdapt::GetErrCodeString
1547 #ifdef NCBI_OS_MSWIN
1552 {
return GetLastError(); }
1553 static const char* GetErrCodeString(
int errnum);
1555 # define NCBI_LASTERROR_CODE_WRAPPER \
1556 NCBI_NS_NCBI::CLastErrorAdapt::GetErrCode
1557 # define NCBI_LASTERROR_STR_WRAPPER \
1558 NCBI_NS_NCBI::CLastErrorAdapt::GetErrCodeString
1573 typedef const char* (*TErrorStr)(
int errnum);
1582 template <
class TBase,
1597 case eErrno:
return "eErrno";
1625 {
return "CErrnoTemplException"; }
1632 return typeid(*this) ==
1647 const string& message,
1650 : TBase(
info, prev_exception, message, severity,
flags),
1653 this->x_Init(
info, message, prev_exception, severity);
1679 NCBI_ERRNO_CODE_WRAPPER,
1680 NCBI_ERRNO_STR_WRAPPER>
1690 const string& message,
1706 #ifdef NCBI_OS_MSWIN
1709 NCBI_LASTERROR_CODE_WRAPPER,
1710 NCBI_LASTERROR_STR_WRAPPER>
1720 const string& message,
1740 #define NCBI_EXCEPTION2_VAR(name, exception_class, err_code, message, extra) \
1741 exception_class name(DIAG_COMPILE_INFO, 0, \
1742 exception_class::err_code, (message), (extra) )
1746 #define NCBI_EXCEPTION2(exception_class, err_code, message, extra) \
1747 NCBI_EXCEPTION2_VAR(NCBI_EXCEPTION_EMPTY_NAME, \
1748 exception_class, err_code, message, extra)
1754 #define NCBI_THROW2(exception_class, err_code, message, extra) \
1755 throw NCBI_EXCEPTION2(exception_class, err_code, message, extra)
1761 #define NCBI_RETHROW2(prev_exception,exception_class,err_code,message,extra) \
1762 throw exception_class(DIAG_COMPILE_INFO, \
1763 &(prev_exception), exception_class::err_code, (message), (extra))
1770 #define NCBI_EXCEPTION_DEFAULT2(exception_class, base_class, extra_type) \
1772 exception_class(const CDiagCompileInfo &info, \
1773 const CException* prev_exception, \
1774 EErrCode err_code,const string& message, \
1775 extra_type extra_param, EDiagSev severity = eDiag_Error) \
1776 : base_class(info, prev_exception, \
1777 (message), extra_param, severity, 0) \
1778 NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION(exception_class, base_class)
void x_Assign(CObject_id &dst, const CObject_id &src)
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
CErrnoTemplExceptionEx –.
CErrnoTemplException –.
Manipulator function wrapper.
CExceptionReporterStream –.
CInvalidParamException –.
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
static char expected_type[20]
ERetriable
Can the action be retried?
@ eRetriable_Unknown
It is unknown if the action can succeed if retried.
int TDiagPostFlags
Binary OR of "EDiagPostFlag".
EDiagSev
Severity level for the posted diagnostics.
@ eDPF_Exception
Default flags to use for exception formatting.
@ eDiag_Trace
Trace message.
@ eDiag_Info
Informational message.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
bool m_MainText
Exception has main text.
string m_File
File to report on.
const string & GetModule(void) const
Get module name used for reporting.
EErrCode
Error types that corelib can generate.
CErrnoTemplExceptionEx(const CDiagCompileInfo &info, const CException *prev_exception, const string &message, int errnum, EDiagSev severity=eDiag_Error, CException::TFlags flags=0)
Constructor (with errno only).
void SetModule(const string &module)
Set module name used for reporting.
const char * Ncbi_strerror(int errnum)
bool IsSetFlag(EFlags flag) const
Check if the flag is set.
virtual const CException * x_Clone(void) const override
Helper clone method.
TErrCodeVal GetErrCodeVal(void) const
static auto check(const V &) -> decltype(declval< ostream & >()<< declval< V >())
CExceptionArgs< TErrCode > & operator|(const CExceptionArgsManip &manip)
CExceptionArgs_Base(void)
bool IsSetModule(void) const
CExceptionArgsManip_Wrapper(FExceptionArgsManip f)
ERetriable GetRetriable(void) const
virtual ~CErrnoTemplExceptionEx(void) noexcept
Destructor.
void SetRetriable(ERetriable retriable)
Set the info about ability to retry an action caused the exception.
const char * NcbiErrnoStr(int errnum)
void Critical(CExceptionArgs_Base &args)
TFlags GetFlags(void) const
void(* FExceptionArgsManip)(CExceptionArgs_Base &)
void Error(CExceptionArgs_Base &args)
void SetErrCodeVal(TErrCodeVal err_code)
static const CExceptionReporter * sm_DefHandler
Default handler.
TFlags m_Flags
Flags, hints, attributes.
TExceptionPtr m_Predecessor
Previous exception.
const T & DbgPrintNP(const CDiagCompileInfo &info, const T &e, const char *e_str)
Create diagnostic stream for printing specified message and "abort()" the program if set by SetThrowT...
TErrCode GetErrCode(void) const
const string & GetFile(void) const
Get file name used for reporting.
void DoThrowTraceAbort(void)
"abort()" the program if set by SetThrowTraceAbort() or $ABORT_ON_THROW.
#define NCBI_ERRNO_CODE_WRAPPER
virtual void operator()(CExceptionArgs_Base &args) const
EErrCode
Error type that an application can generate.
virtual int x_GetErrCode(void) const
Helper method for getting error code.
CErrnoTemplExceptionEx(void)
Default constructor.
Module(const char *module)
ERetriable m_Retriable
In some cases it is known for sure if an action caused the exception can be tried again or not.
ostream & m_Out
Output stream.
static bool sm_DefEnabled
Default enable flag.
#define NCBI_LASTERROR_CODE_WRAPPER
#define NCBI_ERRNO_STR_WRAPPER
virtual void ReportExtra(ostream &out) const override
Report error number on stream.
const char *(* TErrorStr)(int errnum)
Define function type for "error str" function.
const CException * TExceptionPtr
Module(const string &module)
CException & UnsetFlag(EFlags flag)
Unset flag (other flags are left as is)
TSeverity GetSeverity(void) const
#define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION_TEMPL_ERRNO(exception_class, base_class)
Helper macro added to support errno based templatized exceptions.
void Trace(CExceptionArgs_Base &args)
CExceptionArgs< TErrCode > & operator|(const CExceptionArgsManip_Wrapper &manip)
void Warning(CExceptionArgs_Base &args)
CExceptionArgs< TErrCode > operator|(TErrCode err_code, const CExceptionArgsManip &manip)
Exception manipulators. Can be combined with error code using operator|().
CExceptionArgs(TErrCode err_code)
enable_if< ncbi_throw_trace::is_exception< T >::value, const T & >::type DbgPrintEx(const CDiagCompileInfo &info, const T &t, const char *str)
#define NCBI_EXCEPTION_DEFAULT(exception_class, base_class)
To help declare new exception class.
virtual ~CExceptionArgsManip(void)
static int GetErrCode(void)
string m_Function
Function to report on.
FExceptionArgsManip m_Func
CErrnoTemplExceptionEx< TBase, NCBI_NS_NCBI::NcbiErrnoCode, NCBI_NS_NCBI::NcbiErrnoStr > CParent
Parent class type.
const T & DbgPrint(const CDiagCompileInfo &info, const T &e, const char *e_str)
Templated function for printing debug message.
CErrnoTemplExceptionEx(const CErrnoTemplExceptionEx< TBase, PErrCode, PErrStr > &other)
Copy constructor.
void Fatal(CExceptionArgs_Base &args)
virtual const char * GetType(void) const override
Get type of class.
void SetModule(const string &module)
virtual void Report(const char *file, int line, const string &title, const CException &ex, TDiagPostFlags flags=eDPF_Exception) const =0
Report CException with _this_ reporter.
CErrnoTemplException(const CDiagCompileInfo &info, const CException *prev_exception, typename CParent::EErrCode err_code, const string &message, EDiagSev severity=eDiag_Error)
Constructor.
Retriable(ERetriable retriable)
int GetErrno(void) const noexcept
Get error number.
EDiagSev m_Severity
Severity level for the exception.
void Console(CExceptionArgs_Base &args)
bool HasMainText(void) const
Check if exception has main text in the chain.
string m_Module
Module to report on.
const T & DbgPrintP(const CDiagCompileInfo &info, const T &e, const char *e_str)
Print the specified printable object and "abort()" the program if set by SetThrowTraceAbort() or $ABO...
string m_What
What type of exception.
const string & GetClass(void) const
Get class name used for reporting.
const TTo * UppermostCast(const TFrom &from)
Return valid pointer to uppermost derived class only if "from" is _really_ the object of the desired ...
CErrnoTemplException_Win(const CDiagCompileInfo &info, const CException *prev_exception, typename CParent::EErrCode err_code, const string &message, EDiagSev severity=eDiag_Error)
Constructor.
unique_ptr< CStackTrace > m_StackTrace
Saved stack trace.
EErrCode
Error types that an application can generate.
const string & GetModule(void) const
int(* TErrorCode)(void)
Define function type for "error code" function.
END_NAMESPACE(ncbi_throw_trace)
const string & GetFunction(void) const
Get function name used for reporting.
unique_ptr< CRequestContextRef > m_RequestContext
void SetFunction(const string &function)
Set function name used for reporting.
void DoDbgPrint(const CDiagCompileInfo &info, const char *message)
Print the specified debug message.
EDiagSev GetSeverity(void) const
Get exception severity.
TErrCode GetErrCode(void) const
Get error code.
CException & SetFlag(EFlags flag)
Set flag (add to other flags)
void SetSeverity(TSeverity severity)
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
static bool sm_BkgrEnabled
Background reporting enabled flag.
void SetRetriable(ERetriable retriable)
string m_Class
Class to report on.
int GetLine(void) const
Get line number where error occurred.
bool m_InReporter
Reporter flag.
virtual ERetriable GetRetriable(void) const
Retrieve info about ability to retry an action caused the exception.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
EFlags
Miscellaneous generic hints, flags and attributes.
virtual void operator()(CExceptionArgs_Base &args) const
void operator()(CExceptionArgs_Base &args) const
void SetThrowTraceAbort(bool abort_on_throw_trace)
Specify whether to call "abort()" inside the DoThrowTraceAbort().
CErrnoTemplExceptionEx< TBase, NCBI_NS_NCBI::CLastErrorAdapt::GetErrCode, NCBI_NS_NCBI::CLastErrorAdapt::GetErrCodeString > CParent
Parent class type.
void SetClass(const string &nclass)
Set class name used for reporting.
BEGIN_NAMESPACE(ncbi_throw_trace)
string m_Msg
Message string.
const CException * GetPredecessor(void) const
Get "previous" exception from the backlog.
void Info(CExceptionArgs_Base &args)
void SetFlags(TFlags flags)
virtual void operator()(CExceptionArgs_Base &args) const =0
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
@ eCore
Generic corelib error.
@ eDiagFilter
Illegal syntax of the diagnostics filter string.
@ eNullPtr
Null pointer error.
@ eInvalid
To be used ONLY as a return value; please, NEVER throw an exception with this code.
@ fConsole
Mark the exception with this flag if the exception is supposed to be extra-visible,...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
#define NCBI_XNCBI_EXPORT
unsigned int
A callback function used to compare two keys in a database.
const GenericPointer< typename T::ValueType > T2 value
Defines MS Windows specifics for our "C++" code.
Miscellaneous common-use basic types and functionality.