Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PException Class Reference

Poslib exception class. More...

#include <exception.h>

+ Collaboration diagram for PException:

Public Member Functions

 PException ()
 default constructor
 PException (const PException &p)
 copy constructor
 PException (const char *_message)
 constructor with message
 PException (const char *_message, const PException &p)
 constructor with message and another exception
 PException (bool formatted, const char *message,...)
 constructor with format string
 ~PException ()
 destructor
PExceptionoperator= (const PException &p)
 assignment operator

Public Attributes

char * message
 the exception error message

Detailed Description

Poslib exception class.

This is the class all Poslib functions will use when they want to notify the caller in case of an error. It has only one member, message, which is a free-form message describing the error. It can be constructed in various ways: by specifying a message, a format string with arguments, and a combination of a message and an other exception.

Constructor & Destructor Documentation

PException::PException ( )

default constructor

This default constructor for the exception class sets the message to "".

PException::PException ( const PException p)

copy constructor

This destructor makes a copy of another PException.

Parameters
pThe PException to copy
PException::PException ( const char *  _message)

constructor with message

This constructor takes the message to store in the PException. The message parameter will be copied to the PException using a strdup().

Parameters
_messageThe message for the exception
PException::PException ( const char *  _message,
const PException p 
)

constructor with message and another exception

This constructor takes a message, and another PException. The message variable will consists of the _message parameter and the message of the p parameter. This can be really convenient if you want to re-throw an exception, for example:

try {
domainname x = "www.acdam.net";
(...)
} catch (PException p) {
throw PException("Process failed: ", p);
}
Parameters
_messageError message
pException whose message is appended to the error message
PException::PException ( bool  formatted,
const char *  message,
  ... 
)

constructor with format string

This constructor can be used for formatting an error message. The first boolean parameter is only there so that this can be distinguished from other constructors; it has no actual meaning currently (we are thinking what meaning we could give it though - so stay tuned :) ).

This code internally calls vsnprintf, so you don't need to bother about buffer overflows. Do note that the message will be trimmed of at 1024 characters if it becomes too long.

Parameters
formattedIgnored.
messageThe format string message
...Arguments for the format string
PException::~PException ( )

destructor

This destructor frees all memory associated with the exception object.

Member Function Documentation

PException & PException::operator= ( const PException p)

assignment operator

This function assigns the message from the PException p to this object.

Parameters
pThe PException to copy
Returns
This exception object

Member Data Documentation

char* PException::message

the exception error message

The error message of the exception. This is just one piece of free-form text. You can always assume this value is non-NULL.


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