Vault  4.1
Public Member Functions | Static Public Attributes
VException Class Reference

VException is the base class for all exceptions thrown by the Vault. More...

#include <vexception.h>

Inheritance diagram for VException:
VEOFException VRangeException VSocketClosedException VStackTraceException VUnimplementedException VBentoNotFoundException

List of all members.

Public Member Functions

 VException (bool recordStackTrace=false)
 Constructs a VException with default error code and empty message.
 VException (const VException &other, bool recordStackTrace=false)
 Constructs a copy of another VException.
 VException (int error, const char *errorMessage, bool recordStackTrace=false)
 Constructs a VException with error code and static message.
 VException (int error, const VString &errorString, bool recordStackTrace=false)
 Constructs a VException with error code and VString message.
 VException (const char *errorMessage, bool recordStackTrace=false)
 Constructs a VException with default error code and static message.
 VException (const VString &errorString, bool recordStackTrace=false)
 Constructs a VException with default error code and VString message.
 VException (const VSystemError &error, const VString &errorString, bool recordStackTrace=false)
 Constructs a VException with system error and VString message.
virtual ~VException () throw ()
 Destructor.
VExceptionoperator= (const VException &other)
 Assignment operator.
virtual const char * what () const throw ()
 Override of the base class method for extracting the message.
int getError () const
 Returns the exception's error code.
const VStringVectorgetStackTrace () const
 Returns a reference to the string vector containing the stack trace, if collected.

Static Public Attributes

static const int kGenericError = -1
 The default error code.

Detailed Description

VException is the base class for all exceptions thrown by the Vault.

A VException contains an error code integer and an error message strings. Both are optional.

If you need throw an exception due to an out-of-memory situation, you should only use the VException constructors that take a static message value (const char*). This ensures that you do not cause the VException to allocate yet more memory for the VString that would be created otherwise. VException retains the static message's char pointer and does NOT free or delete it on destruction.

Definition at line 228 of file vexception.h.


Constructor & Destructor Documentation

VException::VException ( bool  recordStackTrace = false)

Constructs a VException with default error code and empty message.

Parameters:
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 57 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( const VException other,
bool  recordStackTrace = false 
)

Constructs a copy of another VException.

Note that if the mErrorMessage is non-null, both objects will share a (const char*) value, which neither deletes on destruction since it is owned by the caller.

Parameters:
otherthe exception to copy
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 73 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( int  error,
const char *  errorMessage,
bool  recordStackTrace = false 
)

Constructs a VException with error code and static message.

Parameters:
errorthe error code
errorMessagea static error message
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 89 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( int  error,
const VString errorString,
bool  recordStackTrace = false 
)

Constructs a VException with error code and VString message.

Parameters:
errorthe error code
errorStringthe error message
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 105 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( const char *  errorMessage,
bool  recordStackTrace = false 
)

Constructs a VException with default error code and static message.

Parameters:
errorMessagea static error message
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 121 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( const VString errorString,
bool  recordStackTrace = false 
)

Constructs a VException with default error code and VString message.

Parameters:
errorStringthe error message
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 137 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::VException ( const VSystemError error,
const VString errorString,
bool  recordStackTrace = false 
)

Constructs a VException with system error and VString message.

The internal error message will be formatted from the two.

Parameters:
errorthe error construct
errorStringthe error message
recordStackTraceif true, will attempt to collect stack trace into mCallStack

Definition at line 153 of file vexception.cpp.

References ASSERT_INVARIANT.

VException::~VException ( ) throw () [virtual]

Destructor.

The throw() declaration is required to satisfy the base class std::exception definition.

Definition at line 169 of file vexception.cpp.

References NULL.


Member Function Documentation

VException & VException::operator= ( const VException other)

Assignment operator.

Note that if the mErrorMessage is non-null, both objects will share a (const char*) value, which neither deletes on destruction since it is owned by the caller.

Parameters:
otherthe exception to copy

Definition at line 174 of file vexception.cpp.

References ASSERT_INVARIANT, and getError().

const char * VException::what ( ) const throw () [virtual]

Override of the base class method for extracting the message.

The throw() declaration is required to satisfy the base class std::exception definition.

Returns:
the error message

Definition at line 187 of file vexception.cpp.

References ASSERT_INVARIANT, and NULL.

int VException::getError ( ) const

Returns the exception's error code.

Returns:
the error code

Definition at line 196 of file vexception.cpp.

References ASSERT_INVARIANT.

const VStringVector & VException::getStackTrace ( ) const

Returns a reference to the string vector containing the stack trace, if collected.

The vector will be empty if no stack trace was collected. The reference is invalid when the exception is destructed.

Returns:
the stack trace information, if it was collected

Definition at line 202 of file vexception.cpp.

References ASSERT_INVARIANT.


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

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.