Exception.hpp File Reference

#include "blocxx/BLOCXX_config.h"
#include "blocxx/AutoPtr.hpp"
#include <iosfwd>
#include <exception>
#include <new>
#include <cerrno>

Go to the source code of this file.

Namespaces

namespace  BLOCXX_NAMESPACE
namespace  BLOCXX_NAMESPACE::ExceptionDetail

Classes

class  BLOCXX_NAMESPACE::Exception
 This class is the base of all exceptions thrown by blocxx code. More...
class  BLOCXX_NAMESPACE::ExceptionDetail::FormatMsg
struct  BLOCXX_NAMESPACE::ExceptionDetail::Errno< exType >

Defines

#define BLOCXX_THROW(exType, msg)   throw exType(__FILE__, __LINE__, (msg))
 Throw an exception using __FILE__ and __LINE__.
#define BLOCXX_THROWL(exType, line, msg)   throw exType(__FILE__, (line), (msg))
 This macro is deprecated in 3.1.0.
#define BLOCXX_THROW_SUBEX(exType, msg, subex)
 Throw an exception using __FILE__ and __LINE__.
#define BLOCXX_THROW_ERR(exType, msg, err)   throw exType(__FILE__, __LINE__, (msg), (err))
 Throw an exception using __FILE__ and __LINE__.
#define BLOCXX_THROW_ERRNO(exType)   BLOCXX_THROW_ERRNO1(exType, errno)
 Throw an exception using __FILE__, __LINE__, errno and strerror(errno).
#define BLOCXX_THROW_ERRNO1(exType, errnum)   throw ::BLOCXX_NAMESPACE::ExceptionDetail::Errno< exType >::simple(__FILE__, __LINE__, (errnum))
 Throw an exception using __FILE__, __LINE__, errnum and strerror(errnum).
#define BLOCXX_THROW_ERRNO_MSG(exType, msg)   BLOCXX_THROW_ERRNO_MSG1(exType, (msg), errno)
 Throw an exception using __FILE__, __LINE__, errno and strerror(errno).
#define BLOCXX_THROW_ERRNO_MSG1(exType, msg, errnum)
 Throw an exception using __FILE__, __LINE__, errnum and strerror(errnum).
#define BLOCXX_THROW_ERR_SUBEX(exType, msg, err, subex)   throw exType(__FILE__, __LINE__, (msg), (err), &(subex))
 Throw an exception using __FILE__ and __LINE__.
#define BLOCXX_DECLARE_EXCEPTION2(NAME, BASE)
 Declare a new exception class named <NAME>Exception that derives from <BASE>.
#define BLOCXX_DECLARE_APIEXCEPTION2(NAME, BASE, LINKAGE_SPEC)
 Declare a new exception class named <NAME>Exception that derives from <BASE>.
#define BLOCXX_DECLARE_EXCEPTION(NAME)   BLOCXX_DECLARE_EXCEPTION2(NAME, ::BLOCXX_NAMESPACE::Exception)
 Declare a new exception class named <NAME>Exception that derives from Exception This macro is typically used in a header file.
#define BLOCXX_DECLARE_APIEXCEPTION(NAME, LINKAGE_SPEC)   BLOCXX_DECLARE_APIEXCEPTION2(NAME, ::BLOCXX_NAMESPACE::Exception, LINKAGE_SPEC)
 Declare a new exception class named <NAME>Exception that derives from Exception This macro is typically used in a header file.
#define BLOCXX_DEFINE_EXCEPTION2(NAME, BASE)
 Define a new exception class named <NAME>Exception that derives from <BASE>.
#define BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, BASE, SUB_CLASS_ID)
 Define a new exception class named <NAME>Exception that derives from <BASE>.
#define BLOCXX_DEFINE_EXCEPTION(NAME)   BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, ::BLOCXX_NAMESPACE::Exception, ::BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID)
 Define a new exception class named <NAME>Exception that derives from Exception.
#define BLOCXX_DEFINE_EXCEPTION_WITH_ID(NAME)   BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, ::BLOCXX_NAMESPACE::Exception, ::BLOCXX_NAMESPACE::ExceptionIds::NAME##ExceptionId)
 Define a new exception class named <NAME>Exception that derives from Exception.
#define BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID(NAME, BASE)   BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, BASE, ::BLOCXX_NAMESPACE::ExceptionIds::NAME##ExceptionId)
 Define a new exception class named <NAME>Exception that derives from <BASE>.

Functions

void BLOCXX_NAMESPACE::ExceptionDetail::portable_strerror_r (int errnum, char *buf, unsigned n)
std::ostream & BLOCXX_NAMESPACE::operator<< (std::ostream &os, const Exception &e)
 Writes the exception object to the stream in the form: <file>: <line> <type>: <message>.

Variables

unsigned const BLOCXX_NAMESPACE::ExceptionDetail::BUFSZ = 1024


Define Documentation

#define BLOCXX_DECLARE_APIEXCEPTION NAME,
LINKAGE_SPEC   )     BLOCXX_DECLARE_APIEXCEPTION2(NAME, ::BLOCXX_NAMESPACE::Exception, LINKAGE_SPEC)
 

Declare a new exception class named <NAME>Exception that derives from Exception This macro is typically used in a header file.

Parameters:
NAME The name of the new class (Exception will be postfixed)
LINKAGE_SPEC the linkage specifier. If the BLOCXX_DEFINE_EXCEPTION is part of libblocxx this would BLOCXX_COMMON_API...

Definition at line 375 of file Exception.hpp.

#define BLOCXX_DECLARE_APIEXCEPTION2 NAME,
BASE,
LINKAGE_SPEC   ) 
 

Value:

class LINKAGE_SPEC NAME##Exception : public BASE \
{ \
public: \
   NAME##Exception(const char* file, int line, const char* msg, int errorCode = ::BLOCXX_NAMESPACE::Exception::UNKNOWN_ERROR_CODE, const Exception* otherException = 0, int subClassId = ::BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID); \
   virtual ~NAME##Exception() throw(); \
   virtual const char* type() const; \
   virtual NAME##Exception* clone() const; \
};
Declare a new exception class named <NAME>Exception that derives from <BASE>.

This macro is typically used in a header file. The exception class declaration will be prefaced with the linkage_spec parm. This allows the use of BLOCXX_COMMON_API when declaring exceptions. Example: BLOCXX_DECLARE_APIEXCEPTION(Bogus, CIMException, BLOCXX_COMMON_API)

Parameters:
NAME The name of the new class (Exception will be postfixed)
BASE The base class.
LINKAGE_SPEC The linkage specifier for the exception class.

Definition at line 346 of file Exception.hpp.

#define BLOCXX_DECLARE_EXCEPTION NAME   )     BLOCXX_DECLARE_EXCEPTION2(NAME, ::BLOCXX_NAMESPACE::Exception)
 

Declare a new exception class named <NAME>Exception that derives from Exception This macro is typically used in a header file.

Parameters:
NAME The name of the new class (Exception will be postfixed)

Definition at line 365 of file Exception.hpp.

#define BLOCXX_DECLARE_EXCEPTION2 NAME,
BASE   ) 
 

Value:

class NAME##Exception : public BASE \
{ \
public: \
   NAME##Exception(const char* file, int line, const char* msg, int errorCode = ::BLOCXX_NAMESPACE::Exception::UNKNOWN_ERROR_CODE, const Exception* otherException = 0, int subClassId = ::BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID); \
   virtual ~NAME##Exception() throw(); \
   virtual const char* type() const; \
   virtual NAME##Exception* clone() const; \
};
Declare a new exception class named <NAME>Exception that derives from <BASE>.

This macro is typically used in a header file.

Parameters:
NAME The name of the new class (Exception will be postfixed)
BASE The base class.

Definition at line 325 of file Exception.hpp.

#define BLOCXX_DEFINE_EXCEPTION NAME   )     BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, ::BLOCXX_NAMESPACE::Exception, ::BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID)
 

Define a new exception class named <NAME>Exception that derives from Exception.

The new class will use UNKNOWN_SUBCLASS_ID for the subclass id. Use this macro for internal implementation exceptions that don't have an id. This macro is typically used in a cpp file.

Parameters:
NAME The name of the new class (Exception will be postfixed)

Definition at line 416 of file Exception.hpp.

#define BLOCXX_DEFINE_EXCEPTION2 NAME,
BASE   ) 
 

Value:

NAME##Exception::NAME##Exception(const char* file, int line, const char* msg, int errorCode, const ::BLOCXX_NAMESPACE::Exception* otherException, int subClassId) \
   : BASE(file, line, msg, errorCode, otherException, subClassId) {} \
NAME##Exception::~NAME##Exception() throw() { } \
NAME##Exception* NAME##Exception::clone() const { return new(std::nothrow) NAME##Exception(*this); } \
const char* NAME##Exception::type() const { return #NAME "Exception"; }
Define a new exception class named <NAME>Exception that derives from <BASE>.

The new class will use UNKNOWN_SUBCLASS_ID for the subclass id. This macro is typically used in a cpp file.

Parameters:
NAME The name of the new class (Exception will be postfixed)
BASE The base class.

Definition at line 385 of file Exception.hpp.

#define BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID NAME,
BASE   )     BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, BASE, ::BLOCXX_NAMESPACE::ExceptionIds::NAME##ExceptionId)
 

Define a new exception class named <NAME>Exception that derives from <BASE>.

The new class will use ExceptionIds::<NAME>ExceptionId for the subclass id. Use this macro to create public exceptions that have an id in the BLOCXX_NAMESPACE::ExceptionIds namespace that will derive from BASE This macro is typically used in a cpp file.

Parameters:
NAME The name of the new class (Exception will be postfixed)
BASE The base class.

Definition at line 437 of file Exception.hpp.

#define BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX NAME,
BASE,
SUB_CLASS_ID   ) 
 

Value:

NAME##Exception::NAME##Exception(const char* file, int line, const char* msg, int errorCode, const ::BLOCXX_NAMESPACE::Exception* otherException, int subClassId) \
   : BASE(file, line, msg, errorCode, otherException, subClassId == ::BLOCXX_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID ? (SUB_CLASS_ID) : subClassId) {} \
NAME##Exception::~NAME##Exception() throw() { } \
NAME##Exception* NAME##Exception::clone() const { return new(std::nothrow) NAME##Exception(*this); } \
const char* NAME##Exception::type() const { return #NAME "Exception"; }
Define a new exception class named <NAME>Exception that derives from <BASE>.

The new class will use SUB_CLASS_ID for the subclass id. This macro is typically used in a cpp file.

Parameters:
NAME The name of the new class (Exception will be postfixed)
BASE The base class.
SUB_CLASS_ID The subclass id.

Definition at line 401 of file Exception.hpp.

#define BLOCXX_DEFINE_EXCEPTION_WITH_ID NAME   )     BLOCXX_DEFINE_EXCEPTION_WITH_BASE_AND_ID_AUX(NAME, ::BLOCXX_NAMESPACE::Exception, ::BLOCXX_NAMESPACE::ExceptionIds::NAME##ExceptionId)
 

Define a new exception class named <NAME>Exception that derives from Exception.

The new class will use ExceptionIds::<NAME>ExceptionId for the subclass id. Use this macro to create public exceptions that have an id in the BLOCXX_NAMESPACE::ExceptionIds namespace that derive from Exception This macro is typically used in a cpp file.

Parameters:
NAME The name of the new class (Exception will be postfixed)

Definition at line 426 of file Exception.hpp.

#define BLOCXX_THROW exType,
msg   )     throw exType(__FILE__, __LINE__, (msg))
 

Throw an exception using __FILE__ and __LINE__.

If applicable, BLOCXX_THROW_ERR should be used instead of this macro.

Parameters:
exType The type of the exception
msg The exception message. A string that will be copied.

Definition at line 248 of file Exception.hpp.

Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::accept(), BLOCXX_NAMESPACE::NonRecursiveMutex::acquire(), BLOCXX_NAMESPACE::Mutex::acquire(), BLOCXX_NAMESPACE::SocketAddress::allocEmptyAddress(), BLOCXX_NAMESPACE::badDateTime(), BLOCXX_NAMESPACE::ThreadImpl::cancel(), BLOCXX_NAMESPACE::PosixRegEx::capture(), BLOCXX_NAMESPACE::Condition::Condition(), BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPostWait(), BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPreWait(), BLOCXX_NAMESPACE::PosixRegEx::execute(), BLOCXX_NAMESPACE::FileAppender::FileAppender(), BLOCXX_NAMESPACE::fromHexStr(), BLOCXX_NAMESPACE::PopenStreamsImpl::getExitStatus(), BLOCXX_NAMESPACE::FileSystem::getFileContents(), BLOCXX_NAMESPACE::SocketUtils::getFullyQualifiedHostName(), BLOCXX_NAMESPACE::RWLocker::getReadLock(), BLOCXX_NAMESPACE::RWLocker::getWriteLock(), BLOCXX_NAMESPACE::SelectEngine::go(), BLOCXX_NAMESPACE::PosixRegEx::grep(), BLOCXX_NAMESPACE::IConv_t::IConv_t(), BLOCXX_NAMESPACE::ThreadCounter::incThreadCount(), BLOCXX_NAMESPACE::Thread::join(), BLOCXX_NAMESPACE::DateTime::localTimeAndOffset(), BLOCXX_NAMESPACE::PosixRegEx::match(), BLOCXX_NAMESPACE::IConv::mayThrowStringConversionException(), BLOCXX_NAMESPACE::Mutex::Mutex(), BLOCXX_NAMESPACE::NonRecursiveMutex::NonRecursiveMutex(), BLOCXX_NAMESPACE::NwIface::NwIface(), BLOCXX_NAMESPACE::PosixUnnamedPipe::open(), BLOCXX_NAMESPACE::BinarySerialization::readLen(), BLOCXX_NAMESPACE::TempFileEnumerationImplBase::readSize(), BLOCXX_NAMESPACE::NonRecursiveMutex::release(), BLOCXX_NAMESPACE::Mutex::release(), BLOCXX_NAMESPACE::TempFileEnumerationImplBase::releaseFile(), BLOCXX_NAMESPACE::RWLocker::releaseReadLock(), BLOCXX_NAMESPACE::RWLocker::releaseWriteLock(), BLOCXX_NAMESPACE::PosixRegEx::replace(), BLOCXX_NAMESPACE::Exec::safePopen(), BLOCXX_NAMESPACE::ThreadImpl::saveThreadInTLS(), BLOCXX_NAMESPACE::ThreadImpl::sendSignalToThread(), BLOCXX_NAMESPACE::DateTime::set(), BLOCXX_NAMESPACE::DateTime::setMicrosecond(), BLOCXX_NAMESPACE::DateTime::setMonth(), BLOCXX_NAMESPACE::DateTime::setTime(), BLOCXX_NAMESPACE::Socket::Socket(), BLOCXX_NAMESPACE::PosixRegEx::split(), BLOCXX_NAMESPACE::Thread::start(), BLOCXX_NAMESPACE::UTF8Utils::StringToUCS2Common(), BLOCXX_NAMESPACE::SyslogAppender::SyslogAppender(), BLOCXX_NAMESPACE::TempFileEnumerationImplBase::TempFileEnumerationImplBase(), BLOCXX_NAMESPACE::ThreadBarrierImpl::ThreadBarrierImpl(), BLOCXX_NAMESPACE::throwArrayOutOfBoundsException(), BLOCXX_NAMESPACE::TempFileEnumerationImplBase::throwIfEmpty(), BLOCXX_NAMESPACE::ReferenceBase::throwNULLException(), BLOCXX_NAMESPACE::COWReferenceBase::throwNULLException(), BLOCXX_NAMESPACE::COWIntrusiveReferenceHelpers::throwNULLException(), BLOCXX_NAMESPACE::throwStringConversion(), BLOCXX_NAMESPACE::Condition::timedWait(), BLOCXX_NAMESPACE::TmpFileImpl::TmpFileImpl(), BLOCXX_NAMESPACE::MD5::update(), BLOCXX_NAMESPACE::UUID::UUID(), BLOCXX_NAMESPACE::BinarySerialization::verifySignature(), BLOCXX_NAMESPACE::ThreadBarrierImpl::wait(), BLOCXX_NAMESPACE::Condition::wait(), and BLOCXX_NAMESPACE::ThreadCounter::waitForAll().

#define BLOCXX_THROW_ERR exType,
msg,
err   )     throw exType(__FILE__, __LINE__, (msg), (err))
 

Throw an exception using __FILE__ and __LINE__.

Parameters:
exType The type of the exception
msg The exception message. A string that will be copied.
err The error code.

Definition at line 272 of file Exception.hpp.

Referenced by BLOCXX_NAMESPACE::CmdLineParser::CmdLineParser(), BLOCXX_NAMESPACE::PosixRegEx::grep(), BLOCXX_NAMESPACE::PosixRegEx::operator=(), BLOCXX_NAMESPACE::PosixRegEx::PosixRegEx(), and BLOCXX_NAMESPACE::PosixRegEx::replace().

#define BLOCXX_THROW_ERR_SUBEX exType,
msg,
err,
subex   )     throw exType(__FILE__, __LINE__, (msg), (err), &(subex))
 

Throw an exception using __FILE__ and __LINE__.

Parameters:
exType The type of the exception
msg The exception message. A string that will be copied.
err The error code.
subex A sub-exception. A point to it will be passed to the exception constructor, which should clone() it.

Definition at line 315 of file Exception.hpp.

#define BLOCXX_THROW_ERRNO exType   )     BLOCXX_THROW_ERRNO1(exType, errno)
 

Throw an exception using __FILE__, __LINE__, errno and strerror(errno).

Parameters:
exType The type of the exception; ctor must take file, line, message, and error code.

Definition at line 280 of file Exception.hpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::Path::getCurrentWorkingDirectory(), and BLOCXX_NAMESPACE::FileSystem::readSymbolicLink().

#define BLOCXX_THROW_ERRNO1 exType,
errnum   )     throw ::BLOCXX_NAMESPACE::ExceptionDetail::Errno< exType >::simple(__FILE__, __LINE__, (errnum))
 

Throw an exception using __FILE__, __LINE__, errnum and strerror(errnum).

Parameters:
exType The type of the exception; ctor must take file, line, message, and error code.

Definition at line 287 of file Exception.hpp.

#define BLOCXX_THROW_ERRNO_MSG exType,
msg   )     BLOCXX_THROW_ERRNO_MSG1(exType, (msg), errno)
 

Throw an exception using __FILE__, __LINE__, errno and strerror(errno).

Parameters:
exType The type of the exception; ctor must take file, line, message, and error code.

Definition at line 295 of file Exception.hpp.

Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::close(), BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::ServerSocketImpl::doListen(), BLOCXX_NAMESPACE::ServerSocketImpl::fillAddrParms(), BLOCXX_NAMESPACE::SocketBaseImpl::fillUnixAddrParms(), BLOCXX_NAMESPACE::killWait(), BLOCXX_NAMESPACE::TmpFileImpl::open(), BLOCXX_NAMESPACE::SocketBaseImpl::read(), BLOCXX_NAMESPACE::PosixUnnamedPipe::read(), BLOCXX_NAMESPACE::BinarySerialization::read(), BLOCXX_NAMESPACE::TmpFileImpl::releaseFile(), BLOCXX_NAMESPACE::Exec::safePopen(), BLOCXX_NAMESPACE::PosixUnnamedPipe::setBlocking(), BLOCXX_NAMESPACE::Socket::shutdownAllSockets(), BLOCXX_NAMESPACE::timedWaitPid(), BLOCXX_NAMESPACE::SocketBaseImpl::write(), BLOCXX_NAMESPACE::PosixUnnamedPipe::write(), and BLOCXX_NAMESPACE::BinarySerialization::write().

#define BLOCXX_THROW_ERRNO_MSG1 exType,
msg,
errnum   ) 
 

Value:

throw ::BLOCXX_NAMESPACE::ExceptionDetail::Errno< exType >:: \
      format(__FILE__, __LINE__, (msg), (errnum))
Throw an exception using __FILE__, __LINE__, errnum and strerror(errnum).

Parameters:
exType The type of the exception; ctor must take file, line, message, and error code.

Definition at line 303 of file Exception.hpp.

#define BLOCXX_THROW_SUBEX exType,
msg,
subex   ) 
 

Value:

throw exType(__FILE__, __LINE__, (msg), \
             ::BLOCXX_NAMESPACE::Exception::UNKNOWN_ERROR_CODE, &(subex))
Throw an exception using __FILE__ and __LINE__.

Parameters:
exType The type of the exception
msg The exception message. A string that will be copied.
subex A sub-exception. A pointer to it will be passed to the exception constructor, which should clone() it.

Definition at line 262 of file Exception.hpp.

#define BLOCXX_THROWL exType,
line,
msg   )     throw exType(__FILE__, (line), (msg))
 

This macro is deprecated in 3.1.0.

Definition at line 253 of file Exception.hpp.


Generated on Fri Jun 16 15:39:09 2006 for blocxx by  doxygen 1.4.6