blocxx
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
BLOCXX_NAMESPACE::Exception Class Reference

This class is the base of all exceptions thrown by BloCxx code. More...

#include <Exception.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::Exception:
BLOCXX_NAMESPACE::AssertionException BLOCXX_NAMESPACE::CancellationDeniedException BLOCXX_NAMESPACE::CmdLineParserException BLOCXX_NAMESPACE::ConditionLockException BLOCXX_NAMESPACE::ConditionResourceException BLOCXX_NAMESPACE::DateTimeException BLOCXX_NAMESPACE::DeadlockException BLOCXX_NAMESPACE::EnumerationException BLOCXX_NAMESPACE::ExecErrorException BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException 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::StringConversionException BLOCXX_NAMESPACE::ThreadBarrierException BLOCXX_NAMESPACE::ThreadException BLOCXX_NAMESPACE::ThreadPoolException BLOCXX_NAMESPACE::TimeoutException BLOCXX_NAMESPACE::UnknownHostException BLOCXX_NAMESPACE::UnnamedPipeException BLOCXX_NAMESPACE::UUIDException

Public Member Functions

virtual ~Exception () throw ()
 
virtual const char * type () const
 Returns a string representing the concrete type. More...
 
virtual const char * getMessage () const
 Returns the message. More...
 
const char * getFile () const
 Returns the file. More...
 
int getLine () const
 
int getSubClassId () const
 
const ExceptiongetSubException () const
 Returns the sub exception if available, otherwise 0. More...
 
int getErrorCode () const
 Returns the error code representing the error which occurred. More...
 
virtual const char * what () const throw ()
 Returns getMessage() More...
 
virtual Exceptionclone () const
 Make a copy of this exception object. More...
 
virtual void rethrow () const
 Re-throws the exception. More...
 
char * dupString (const char *str)
 Utility function to copy a string. More...
 

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. More...
 
 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)
 
Exceptionoperator= (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 Exceptionm_subException
 
int m_errorCode
 

Detailed Description

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 95 of file Exception.hpp.

Constructor & Destructor Documentation

◆ Exception() [1/4]

BLOCXX_NAMESPACE::Exception::Exception ( const char *  file,
int  line,
const char *  msg 
)
protected

This constructor is deprecated.

Definition at line 116 of file Exception.cpp.

◆ Exception() [2/4]

BLOCXX_NAMESPACE::Exception::Exception ( const char *  file,
int  line,
const char *  msg,
int  errorCode,
const Exception otherException = 0,
int  subClassId = UNKNOWN_SUBCLASS_ID 
)
protected
Parameters
fileThe filename of the code throwing the exception.
lineThe line of the code throwing the exception.
msgA human readable message associated with the exception.
errorCodeA number identifying the specific error that caused this exception.
otherExceptionA 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.
subClassIdEach 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 150 of file Exception.cpp.

◆ Exception() [3/4]

BLOCXX_NAMESPACE::Exception::Exception ( int  subClassId,
const char *  file,
int  line,
const char *  msg,
int  errorCode,
const Exception otherException = 0 
)
protected

Definition at line 133 of file Exception.cpp.

◆ Exception() [4/4]

BLOCXX_NAMESPACE::Exception::Exception ( const Exception e)
protected

Definition at line 167 of file Exception.cpp.

◆ ~Exception()

BLOCXX_NAMESPACE::Exception::~Exception ( )
throw (
)
virtual

Definition at line 181 of file Exception.cpp.

Member Function Documentation

◆ clone()

Exception * BLOCXX_NAMESPACE::Exception::clone ( ) const
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::SafeCString::OverflowException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::UnnamedPipeException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::FileSystemException, and BLOCXX_NAMESPACE::UUIDException.

Definition at line 311 of file Exception.cpp.

◆ dupString()

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 101 of file Exception.cpp.

◆ getErrorCode()

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 331 of file Exception.cpp.

◆ getFile()

const char * BLOCXX_NAMESPACE::Exception::getFile ( ) const

Returns the file.

May return 0.

Definition at line 239 of file Exception.cpp.

◆ getLine()

int BLOCXX_NAMESPACE::Exception::getLine ( ) const

Definition at line 226 of file Exception.cpp.

◆ getMessage()

const char * BLOCXX_NAMESPACE::Exception::getMessage ( ) const
virtual

Returns the message.

May return 0. This function will not throw. Derived class implementations must not throw.

Definition at line 233 of file Exception.cpp.

◆ getSubClassId()

int BLOCXX_NAMESPACE::Exception::getSubClassId ( ) const

Definition at line 297 of file Exception.cpp.

◆ getSubException()

const Exception * BLOCXX_NAMESPACE::Exception::getSubException ( ) const

Returns the sub exception if available, otherwise 0.

Definition at line 324 of file Exception.cpp.

◆ operator=()

Exception & BLOCXX_NAMESPACE::Exception::operator= ( const Exception rhs)
protected

Definition at line 199 of file Exception.cpp.

◆ rethrow()

void BLOCXX_NAMESPACE::Exception::rethrow ( ) const
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::SafeCString::OverflowException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::UnnamedPipeException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::FileSystemException, and BLOCXX_NAMESPACE::UUIDException.

Definition at line 317 of file Exception.cpp.

◆ setErrorCode()

void BLOCXX_NAMESPACE::Exception::setErrorCode ( int  errorCode)
protected

Definition at line 338 of file Exception.cpp.

◆ setSubClassId()

void BLOCXX_NAMESPACE::Exception::setSubClassId ( int  subClassId)
protected

Definition at line 304 of file Exception.cpp.

◆ swap()

void BLOCXX_NAMESPACE::Exception::swap ( Exception x)
protected

Definition at line 206 of file Exception.cpp.

◆ type()

const char * BLOCXX_NAMESPACE::Exception::type ( ) const
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::SafeCString::OverflowException, BLOCXX_NAMESPACE::MD5Exception, BLOCXX_NAMESPACE::SocketTimeoutException, BLOCXX_NAMESPACE::Secure::ProcessAbortException, BLOCXX_NAMESPACE::CancellationDeniedException, BLOCXX_NAMESPACE::GenericRWLockImplException, BLOCXX_NAMESPACE::DateTimeException, BLOCXX_NAMESPACE::LoggerException, BLOCXX_NAMESPACE::ProcessErrorException, BLOCXX_NAMESPACE::UnnamedPipeException, BLOCXX_NAMESPACE::OutOfBoundsException, BLOCXX_NAMESPACE::SelectException, BLOCXX_NAMESPACE::ExecErrorException, BLOCXX_NAMESPACE::StringConversionException, BLOCXX_NAMESPACE::UnknownHostException, BLOCXX_NAMESPACE::CmdLineParserException, BLOCXX_NAMESPACE::ConditionLockException, BLOCXX_NAMESPACE::LogMessagePatternFormatterException, BLOCXX_NAMESPACE::InvalidUTF8Exception, BLOCXX_NAMESPACE::FileSystemMockObjectUnimplementedException, BLOCXX_NAMESPACE::RegExCompileException, BLOCXX_NAMESPACE::IOException, BLOCXX_NAMESPACE::DeadlockException, BLOCXX_NAMESPACE::RWLockerException, BLOCXX_NAMESPACE::SSLException, BLOCXX_NAMESPACE::AssertionException, BLOCXX_NAMESPACE::EnumerationException, BLOCXX_NAMESPACE::SharedLibraryException, BLOCXX_NAMESPACE::SocketException, BLOCXX_NAMESPACE::TimeoutException, BLOCXX_NAMESPACE::ExecMockObjectUnimplementedException, BLOCXX_NAMESPACE::NULLValueException, BLOCXX_NAMESPACE::ThreadException, BLOCXX_NAMESPACE::RegExExecuteException, BLOCXX_NAMESPACE::ExecBufferFullException, BLOCXX_NAMESPACE::ExecTimeoutException, BLOCXX_NAMESPACE::ThreadPoolException, BLOCXX_NAMESPACE::SocketAddressException, BLOCXX_NAMESPACE::ConditionResourceException, BLOCXX_NAMESPACE::ThreadBarrierException, BLOCXX_NAMESPACE::BadSignatureException, BLOCXX_NAMESPACE::FileSystemException, and BLOCXX_NAMESPACE::UUIDException.

Definition at line 219 of file Exception.cpp.

◆ what()

const char * BLOCXX_NAMESPACE::Exception::what ( ) const
throw (
)
virtual

Returns getMessage()

Definition at line 290 of file Exception.cpp.

Member Data Documentation

◆ m_errorCode

int BLOCXX_NAMESPACE::Exception::m_errorCode
private

Definition at line 240 of file Exception.hpp.

◆ m_file

char* BLOCXX_NAMESPACE::Exception::m_file
private

Definition at line 235 of file Exception.hpp.

◆ m_line

int BLOCXX_NAMESPACE::Exception::m_line
private

Definition at line 236 of file Exception.hpp.

◆ m_msg

char* BLOCXX_NAMESPACE::Exception::m_msg
private

Definition at line 237 of file Exception.hpp.

◆ m_subClassId

int BLOCXX_NAMESPACE::Exception::m_subClassId
private

Definition at line 238 of file Exception.hpp.

◆ m_subException

const Exception* BLOCXX_NAMESPACE::Exception::m_subException
private

Definition at line 239 of file Exception.hpp.

◆ UNKNOWN_ERROR_CODE

const int BLOCXX_NAMESPACE::Exception::UNKNOWN_ERROR_CODE = -1
static

Definition at line 173 of file Exception.hpp.

◆ UNKNOWN_SUBCLASS_ID

const int BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID = -1
static

Definition at line 172 of file Exception.hpp.


The documentation for this class was generated from the following files: