39#include "blocxx/BLOCXX_config.h"
43#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
50#if defined(BLOCXX_HAVE_ISTREAM) && defined(BLOCXX_HAVE_OSTREAM)
61#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
62Mutex* Exception::m_mutex =
new Mutex();
77 char* rv =
new (std::nothrow)
char[strlen(str)+1];
90 , m_msg(dupString(msg))
91 , m_subClassId(UNKNOWN_SUBCLASS_ID)
93 , m_errorCode(UNKNOWN_ERROR_CODE)
95#ifdef BLOCXX_ENABLE_STACK_TRACE_ON_EXCEPTIONS
98#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
107 , m_msg(dupString(msg))
108 , m_subClassId(subClassId)
109 , m_subException(subException ? subException->clone() : 0)
110 , m_errorCode(errorCode)
112#ifdef BLOCXX_ENABLE_STACK_TRACE_ON_EXCEPTIONS
115#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
124 , m_msg(dupString(msg))
125 , m_subClassId(subClassId)
126 , m_subException(subException ? subException->clone() : 0)
127 , m_errorCode(errorCode)
129#ifdef BLOCXX_ENABLE_STACK_TRACE_ON_EXCEPTIONS
132#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
141 , m_msg(dupString(e.m_msg))
142 , m_subClassId(e.m_subClassId)
143 , m_subException(e.m_subException ? e.m_subException->clone() : 0)
144 , m_errorCode(e.m_errorCode)
146#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
158#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
178 std::swap(
static_cast<std::exception&
>(*
this),
static_cast<std::exception&
>(rhs));
235 os << e.
type() <<
": ";
244 os <<
"[no message]";
254 os <<
" <" << *subEx <<
'>';
283 return new(std::nothrow)
Exception(*
this);
313namespace ExceptionDetail
317#if defined(BLOCXX_HPUX) || defined(BLOCXX_SOLARIS) || defined(BLOCXX_WIN32) || defined(BLOCXX_NCR)
321 ::strncpy(buf, strerror(errnum), n);
327 typedef char * (*gnu_fct)(int,
char *, ::std::size_t);
337 template <
typename Dummy>
342 return strerror_r(errnum, buf, n);
345 template <
typename Dummy>
350 return strerror_r(errnum, buf, n);
353 template <
typename Dummy>
358 char * errstr = strerror_r(errnum, buf, n);
363 ::strncpy(buf, errstr, n);
378 ::strncpy(buf,
"[Could not create error message for error code]", n);
394 char const * sarr =
static_cast<char const *
>(arr);
NonRecursiveMutex m_mutex
This class is the base of all exceptions thrown by BloCxx code.
virtual const char * what() const
Returns getMessage()
int getErrorCode() const
Returns the error code representing the error which occurred.
int getSubClassId() const
void setSubClassId(int subClassId)
virtual const char * getMessage() const
Returns the message.
const Exception * m_subException
Exception(const char *file, int line, const char *msg) BLOCXX_DEPRECATED
This constructor is deprecated.
const char * getFile() const
Returns the file.
void setErrorCode(int errorCode)
virtual void rethrow() const
Re-throws the exception.
const Exception * getSubException() const
Returns the sub exception if available, otherwise 0.
virtual const char * type() const
Returns a string representing the concrete type.
static const int UNKNOWN_ERROR_CODE
char * dupString(const char *str)
Utility function to copy a string.
Exception & operator=(const Exception &rhs)
virtual Exception * clone() const
Make a copy of this exception object.
This String class is an abstract data type that represents as NULL terminated string of characters.
const char * c_str() const
int(* aix_fct)(int, char *, int)
char *(* gnu_fct)(int, char *, ::std::size_t)
int strerror_r_wrap(posix_fct strerror_r, int errnum, char *buf, unsigned n, Dummy)
void portable_strerror_r(int errnum, char *buf, unsigned n)
int(* posix_fct)(int, char *, ::std::size_t)
BLOCXX_COMMON_API void printStackTrace(EDoStackTraceFlag=E_CHECK_ENV_VAR)
static void freeBuf(char **ptr)
ostream & operator<<(ostream &ostrm, const Bool &arg)