blocxx
|
This class is the base of all exceptions thrown by BloCxx code. More...
#include <Exception.hpp>
Public Member Functions | |
virtual | ~Exception () throw () |
virtual const char * | type () const |
Returns a string representing the concrete type. | |
virtual const char * | getMessage () const |
Returns the message. | |
const char * | getFile () const |
Returns the file. | |
int | getLine () const |
int | getSubClassId () const |
const Exception * | getSubException () const |
Returns the sub exception if available, otherwise 0. | |
int | getErrorCode () const |
Returns the error code representing the error which occurred. | |
virtual const char * | what () const throw () |
Returns getMessage() | |
virtual Exception * | clone () const |
Make a copy of this exception object. | |
virtual void | rethrow () const |
Re-throws the exception. | |
char * | dupString (const char *str) |
Utility function to copy a string. | |
Static Public Attributes | |
static const int | UNKNOWN_SUBCLASS_ID = -1 |
static const int | UNKNOWN_ERROR_CODE = -1 |
Protected Member Functions | |
Exception (const char *file, int line, const char *msg) BLOCXX_DEPRECATED | |
This constructor is deprecated. | |
Exception (const char *file, int line, const char *msg, int errorCode, const Exception *otherException=0, int subClassId=UNKNOWN_SUBCLASS_ID) | |
Exception (int subClassId, const char *file, int line, const char *msg, int errorCode, const Exception *otherException=0) BLOCXX_DEPRECATED | |
Exception (const Exception &e) | |
Exception & | operator= (const Exception &rhs) |
void | swap (Exception &x) |
void | setSubClassId (int subClassId) |
void | setErrorCode (int errorCode) |
Private Attributes | |
char * | m_file |
int | m_line |
char * | m_msg |
int | m_subClassId |
const Exception * | m_subException |
int | m_errorCode |
This class is the base of all exceptions thrown by BloCxx code.
It cannot be constructed directly, only subclasses can be instantiated.
Creating a correct subclass is facilitated by the macros defined in this file.
Exceptions should be thrown by using one of the BLOCXX_THROW_* macros which inserts the file and line number among other helpful things.
Definition at line 65 of file Exception.hpp.
|
protected |
This constructor is deprecated.
Definition at line 86 of file Exception.cpp.
References dupString(), m_errorCode, m_file, m_line, m_msg, m_subClassId, m_subException, BLOCXX_NAMESPACE::StackTrace::printStackTrace(), UNKNOWN_ERROR_CODE, and UNKNOWN_SUBCLASS_ID.
Referenced by clone(), Exception(), Exception(), Exception(), operator=(), and swap().
|
protected |
file | The filename of the code throwing the exception. |
line | The line of the code throwing the exception. |
msg | A human readable message associated with the exception. |
errorCode | A number identifying the specific error that caused this exception. |
otherException | A pointer to another exception. This allows for exception chaining, presumably otherException is the underlying cause that the current exception is being thrown. If otherException != 0, The new Exception instance will store and delete the result of calling otherException->clone(). otherException will not be saved. |
subClassId | Each subclass of Exception may create an id. getSubClassId() will return this value. You may pass UNKNOWN_SUBCLASS_ID if no id is required. blocxx Ids are be registered in BLOCXX_ExceptionIds.hpp. |
Definition at line 120 of file Exception.cpp.
References clone(), dupString(), Exception(), m_errorCode, m_file, m_line, m_msg, m_subClassId, m_subException, and BLOCXX_NAMESPACE::StackTrace::printStackTrace().
|
protected |
Definition at line 103 of file Exception.cpp.
References clone(), dupString(), Exception(), m_errorCode, m_file, m_line, m_msg, m_subClassId, m_subException, and BLOCXX_NAMESPACE::StackTrace::printStackTrace().
|
protected |
Definition at line 137 of file Exception.cpp.
References clone(), dupString(), Exception(), m_errorCode, m_file, m_line, m_msg, m_subClassId, and m_subException.
|
virtual |
Definition at line 151 of file Exception.cpp.
References BLOCXX_NAMESPACE::freeBuf(), m_file, m_msg, and m_subException.
|
virtual |
Make a copy of this exception object.
If allocation fails, return 0. Subclasses need to override this function. This function must not throw. Here is an example of how to implement this in a derived class:
virtual DerivedException* clone() const { return new(std::nothrow) DerivedException(*this); }
Reimplemented in BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::FileSystemException, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SafeCString::OverflowException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::UnnamedPipeException, and BLOCXX_NAMESPACE::UUIDException.
Definition at line 281 of file Exception.cpp.
References Exception().
Referenced by Exception(), Exception(), and Exception().
char * BLOCXX_NAMESPACE::Exception::dupString | ( | const char * | str | ) |
Utility function to copy a string.
This function will not throw–if allocation fails, 0 is returned. The result must be free[]'d. if str == 0, 0 is returned. TODO: This function doesn't really belong on this class, but so far only this class and subclasses have a use for it.
Definition at line 71 of file Exception.cpp.
Referenced by Exception(), Exception(), Exception(), and Exception().
int BLOCXX_NAMESPACE::Exception::getErrorCode | ( | ) | const |
Returns the error code representing the error which occurred.
Code are unique only in the scope of the derived exception class. May return UNKNONWN_ERROR_CODE if the error is unavailable.
Definition at line 301 of file Exception.cpp.
References m_errorCode.
Referenced by BLOCXX_NAMESPACE::operator<<().
const char * BLOCXX_NAMESPACE::Exception::getFile | ( | ) | const |
Returns the file.
May return 0.
Definition at line 209 of file Exception.cpp.
References m_file.
Referenced by BLOCXX_NAMESPACE::operator<<().
int BLOCXX_NAMESPACE::Exception::getLine | ( | ) | const |
Definition at line 196 of file Exception.cpp.
References m_line.
Referenced by BLOCXX_NAMESPACE::operator<<().
|
virtual |
Returns the message.
May return 0. This function will not throw. Derived class implementations must not throw.
Definition at line 203 of file Exception.cpp.
References m_msg.
Referenced by BLOCXX_NAMESPACE::LogAppender::createLogAppender(), BLOCXX_NAMESPACE::operator<<(), and what().
int BLOCXX_NAMESPACE::Exception::getSubClassId | ( | ) | const |
Definition at line 267 of file Exception.cpp.
References m_subClassId.
const Exception * BLOCXX_NAMESPACE::Exception::getSubException | ( | ) | const |
Returns the sub exception if available, otherwise 0.
Definition at line 294 of file Exception.cpp.
References m_subException.
Referenced by BLOCXX_NAMESPACE::operator<<().
Definition at line 169 of file Exception.cpp.
References Exception(), and swap().
|
virtual |
Re-throws the exception.
All derived classes should override this which makes it possible to catch a base class Exception and still re-thrown the derived class.
Reimplemented in BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::FileSystemException, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SafeCString::OverflowException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::UnnamedPipeException, and BLOCXX_NAMESPACE::UUIDException.
Definition at line 287 of file Exception.cpp.
|
protected |
Definition at line 308 of file Exception.cpp.
References m_errorCode.
|
protected |
Definition at line 274 of file Exception.cpp.
References m_subClassId.
|
protected |
Definition at line 176 of file Exception.cpp.
References Exception(), m_errorCode, m_file, m_line, m_msg, m_subClassId, and m_subException.
Referenced by operator=().
|
virtual |
Returns a string representing the concrete type.
e.g. "SocketException". Will not return 0. This function will not throw. Derived class implementations must not throw.
Reimplemented in BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::FileSystemException, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SafeCString::OverflowException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::UnnamedPipeException, and BLOCXX_NAMESPACE::UUIDException.
Definition at line 189 of file Exception.cpp.
Referenced by BLOCXX_NAMESPACE::operator<<(), and BLOCXX_NAMESPACE::Thread::threadRunner().
|
virtual |
Returns getMessage()
Definition at line 260 of file Exception.cpp.
References getMessage().
Referenced by BLOCXX_NAMESPACE::Thread::threadRunner().
|
private |
Definition at line 180 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getErrorCode(), setErrorCode(), and swap().
|
private |
Definition at line 175 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getFile(), swap(), and ~Exception().
|
private |
Definition at line 176 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getLine(), and swap().
|
private |
Definition at line 177 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getMessage(), swap(), and ~Exception().
|
private |
Definition at line 178 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getSubClassId(), setSubClassId(), and swap().
|
private |
Definition at line 179 of file Exception.hpp.
Referenced by Exception(), Exception(), Exception(), Exception(), getSubException(), swap(), and ~Exception().
|
static |
Definition at line 113 of file Exception.hpp.
Referenced by Exception(), and BLOCXX_NAMESPACE::operator<<().
|
static |
Definition at line 112 of file Exception.hpp.
Referenced by Exception().