OW_NAMESPACE::Exception Class Reference

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

#include <OW_Exception.hpp>

Inheritance diagram for OW_NAMESPACE::Exception:

Inheritance graph
[legend]
Collaboration diagram for OW_NAMESPACE::Exception:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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 ExceptiongetSubException () 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 Exceptionclone () const
 Make a copy of this exception object.
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)
 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)
 Exception (const Exception &e)
Exceptionoperator= (const Exception &rhs)
void swap (Exception &x)
virtual ~Exception () throw ()
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 OpenWBEM 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 OW_THROW_* macros which inserts the file and line number among other helpful things.

Definition at line 62 of file OW_Exception.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::Exception::Exception const char *  file,
int  line,
const char *  msg
[protected]
 

This constructor is deprecated.

Definition at line 83 of file OW_Exception.cpp.

References OW_NAMESPACE::Mutex::acquire(), m_mutex, and OW_NAMESPACE::StackTrace::printStackTrace().

Referenced by clone(), and operator=().

OW_NAMESPACE::Exception::Exception const char *  file,
int  line,
const char *  msg,
int  errorCode,
const Exception otherException = 0,
int  subClassId = UNKNOWN_SUBCLASS_ID
[protected]
 

Parameters:
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. OW Ids are be registered in OW_ExceptionIds.hpp.

Definition at line 117 of file OW_Exception.cpp.

References OW_NAMESPACE::Mutex::acquire(), m_mutex, and OW_NAMESPACE::StackTrace::printStackTrace().

OW_NAMESPACE::Exception::Exception int  subClassId,
const char *  file,
int  line,
const char *  msg,
int  errorCode,
const Exception otherException = 0
[protected]
 

Definition at line 100 of file OW_Exception.cpp.

References OW_NAMESPACE::Mutex::acquire(), m_mutex, and OW_NAMESPACE::StackTrace::printStackTrace().

OW_NAMESPACE::Exception::Exception const Exception e  )  [protected]
 

Definition at line 134 of file OW_Exception.cpp.

References OW_NAMESPACE::Mutex::acquire(), and m_mutex.

OW_NAMESPACE::Exception::~Exception  )  throw () [protected, virtual]
 

Definition at line 148 of file OW_Exception.cpp.

References OW_NAMESPACE::freeBuf(), m_file, m_msg, m_mutex, m_subException, and OW_NAMESPACE::Mutex::release().


Member Function Documentation

Exception * OW_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 OW_NAMESPACE::CIMException, OW_NAMESPACE::OutOfBoundsException, OW_NAMESPACE::AssertionException, OW_NAMESPACE::CmdLineParserException, OW_NAMESPACE::ConditionLockException, OW_NAMESPACE::ConditionResourceException, OW_NAMESPACE::ConfigException, OW_NAMESPACE::NULLCOWIntrusiveReferenceException, OW_NAMESPACE::NULLCOWReferenceException, OW_NAMESPACE::CryptographicRandomNumberException, OW_NAMESPACE::DateTimeException, OW_NAMESPACE::EnumerationException, OW_NAMESPACE::ExecTimeoutException, OW_NAMESPACE::ExecBufferFullException, OW_NAMESPACE::ExecErrorException, OW_NAMESPACE::FileSystemException, OW_NAMESPACE::IOException, OW_NAMESPACE::BadCIMSignatureException, OW_NAMESPACE::LoggerException, OW_NAMESPACE::LogMessagePatternFormatterException, OW_NAMESPACE::MD5Exception, OW_NAMESPACE::DeadlockException, OW_NAMESPACE::NoSuchPropertyException, OW_NAMESPACE::NoSuchProviderException, OW_NAMESPACE::NoSuchQualifierException, OW_NAMESPACE::NULLValueException, OW_NAMESPACE::ContextDataNotFoundException, OW_NAMESPACE::NULLReferenceException, OW_NAMESPACE::RWLockerException, OW_NAMESPACE::SelectException, OW_NAMESPACE::SharedLibraryException, OW_NAMESPACE::StringConversionException, OW_NAMESPACE::CancellationDeniedException, OW_NAMESPACE::ThreadException, OW_NAMESPACE::ThreadBarrierException, OW_NAMESPACE::ThreadPoolException, OW_NAMESPACE::TimeoutException, OW_NAMESPACE::UnnamedPipeException, OW_NAMESPACE::MalformedURLException, OW_NAMESPACE::InvalidUTF8Exception, OW_NAMESPACE::UUIDException, OW_NAMESPACE::HTTPException, and OW_NAMESPACE::XMLParseException.

Definition at line 273 of file OW_Exception.cpp.

References Exception().

char * OW_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 68 of file OW_Exception.cpp.

int OW_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 287 of file OW_Exception.cpp.

References m_errorCode.

const char * OW_NAMESPACE::Exception::getFile  )  const
 

Returns the file.

May return 0.

Definition at line 206 of file OW_Exception.cpp.

References m_file.

Referenced by OW_NAMESPACE::CIMServer::execQuery(), and OW_NAMESPACE::operator<<().

int OW_NAMESPACE::Exception::getLine  )  const
 

Definition at line 193 of file OW_Exception.cpp.

References m_line.

Referenced by OW_NAMESPACE::CIMServer::execQuery().

const char * OW_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 200 of file OW_Exception.cpp.

References m_msg.

Referenced by OW_NAMESPACE::CIMServer::_getAssociatorProvider(), OW_NAMESPACE::CIMServer::_getInstanceProvider(), OW_NAMESPACE::CIMServer::_getSecondaryInstanceProviders(), OW_NAMESPACE::CIMServer::execQuery(), OW_NAMESPACE::HTTPException::getId(), OW_NAMESPACE::AuthManager::init(), OW_NAMESPACE::WQLSelectStatementGen::visit_aExprConst_BITCONST(), OW_NAMESPACE::WQLSelectStatementGen::visit_aExprConst_FCONST(), OW_NAMESPACE::WQLProcessor::visit_aExprConst_FCONST(), OW_NAMESPACE::WQLSelectStatementGen::visit_aExprConst_HEXCONST(), OW_NAMESPACE::WQLSelectStatementGen::visit_aExprConst_ICONST(), OW_NAMESPACE::WQLProcessor::visit_aExprConst_ICONST(), and what().

int OW_NAMESPACE::Exception::getSubClassId  )  const
 

Definition at line 259 of file OW_Exception.cpp.

References m_subClassId.

const Exception * OW_NAMESPACE::Exception::getSubException  )  const
 

Returns the sub exception if available, otherwise 0.

Definition at line 280 of file OW_Exception.cpp.

References m_subException.

Exception & OW_NAMESPACE::Exception::operator= const Exception rhs  )  [protected]
 

Definition at line 166 of file OW_Exception.cpp.

References Exception().

void OW_NAMESPACE::Exception::setErrorCode int  errorCode  )  [protected]
 

Definition at line 294 of file OW_Exception.cpp.

References m_errorCode.

void OW_NAMESPACE::Exception::setSubClassId int  subClassId  )  [protected]
 

Definition at line 266 of file OW_Exception.cpp.

References m_subClassId.

void OW_NAMESPACE::Exception::swap Exception x  )  [protected]
 

Definition at line 173 of file OW_Exception.cpp.

References m_errorCode, m_file, m_line, m_msg, m_subClassId, m_subException, and OW_NAMESPACE::swap().

const char * OW_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 OW_NAMESPACE::CIMException, OW_NAMESPACE::OutOfBoundsException, OW_NAMESPACE::AssertionException, OW_NAMESPACE::CIMErrorException, OW_NAMESPACE::CmdLineParserException, OW_NAMESPACE::ConditionLockException, OW_NAMESPACE::ConditionResourceException, OW_NAMESPACE::ConfigException, OW_NAMESPACE::NULLCOWIntrusiveReferenceException, OW_NAMESPACE::NULLCOWReferenceException, OW_NAMESPACE::CryptographicRandomNumberException, OW_NAMESPACE::DateTimeException, OW_NAMESPACE::EnumerationException, OW_NAMESPACE::ExecTimeoutException, OW_NAMESPACE::ExecBufferFullException, OW_NAMESPACE::ExecErrorException, OW_NAMESPACE::FileSystemException, OW_NAMESPACE::IOException, OW_NAMESPACE::BadCIMSignatureException, OW_NAMESPACE::LoggerException, OW_NAMESPACE::LogMessagePatternFormatterException, OW_NAMESPACE::MD5Exception, OW_NAMESPACE::DeadlockException, OW_NAMESPACE::NoSuchPropertyException, OW_NAMESPACE::NoSuchProviderException, OW_NAMESPACE::NoSuchQualifierException, OW_NAMESPACE::NULLValueException, OW_NAMESPACE::ContextDataNotFoundException, OW_NAMESPACE::NULLReferenceException, OW_NAMESPACE::RWLockerException, OW_NAMESPACE::SelectException, OW_NAMESPACE::SharedLibraryException, OW_NAMESPACE::StringConversionException, OW_NAMESPACE::CancellationDeniedException, OW_NAMESPACE::ThreadException, OW_NAMESPACE::ThreadBarrierException, OW_NAMESPACE::ThreadPoolException, OW_NAMESPACE::TimeoutException, OW_NAMESPACE::UnnamedPipeException, OW_NAMESPACE::MalformedURLException, OW_NAMESPACE::InvalidUTF8Exception, OW_NAMESPACE::UUIDException, OW_NAMESPACE::HTTPException, and OW_NAMESPACE::XMLParseException.

Definition at line 186 of file OW_Exception.cpp.

Referenced by OW_NAMESPACE::AuthManager::init(), OW_NAMESPACE::runRunnable(), and OW_NAMESPACE::Thread::threadRunner().

const char * OW_NAMESPACE::Exception::what  )  const throw () [virtual]
 

Returns getMessage().

Definition at line 252 of file OW_Exception.cpp.

References getMessage().

Referenced by OW_NAMESPACE::BaseStreamBuffer::buffer_out(), OW_NAMESPACE::runRunnable(), and OW_NAMESPACE::BaseStreamBuffer::underflow().


Member Data Documentation

int OW_NAMESPACE::Exception::m_errorCode [private]
 

Definition at line 171 of file OW_Exception.hpp.

Referenced by getErrorCode(), setErrorCode(), and swap().

char* OW_NAMESPACE::Exception::m_file [private]
 

Definition at line 166 of file OW_Exception.hpp.

Referenced by getFile(), swap(), and ~Exception().

int OW_NAMESPACE::Exception::m_line [private]
 

Definition at line 167 of file OW_Exception.hpp.

Referenced by getLine(), and swap().

char* OW_NAMESPACE::Exception::m_msg [private]
 

Definition at line 168 of file OW_Exception.hpp.

Referenced by getMessage(), swap(), and ~Exception().

int OW_NAMESPACE::Exception::m_subClassId [private]
 

Definition at line 169 of file OW_Exception.hpp.

Referenced by getSubClassId(), setSubClassId(), and swap().

const Exception* OW_NAMESPACE::Exception::m_subException [private]
 

Definition at line 170 of file OW_Exception.hpp.

Referenced by getSubException(), swap(), and ~Exception().

const int OW_NAMESPACE::Exception::UNKNOWN_ERROR_CODE = -1 [static]
 

Definition at line 110 of file OW_Exception.hpp.

const int OW_NAMESPACE::Exception::UNKNOWN_SUBCLASS_ID = -1 [static]
 

Definition at line 109 of file OW_Exception.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:13:44 2006 for openwbem by  doxygen 1.4.6