Libthreadar  1.0.1
 All Classes Namespaces Files Functions Macros
Public Member Functions | Protected Member Functions | List of all members
libthreadar::exception_base Class Referenceabstract

Pure virtual class parent of all webdar exceptions. More...

#include <exceptions.hpp>

Inherited by libthreadar::exception_bug, libthreadar::exception_feature, libthreadar::exception_memory, libthreadar::exception_range, libthreadar::exception_system, and libthreadar::exception_thread.

Public Member Functions

 exception_base (const std::string &x_msg)
 constructor More...
 
virtual ~exception_base ()
 destructor
 
void push_message (const std::string &x_msg)
 to be used in a catch clause to add context information before rethrowing the exception
 
unsigned int size () const
 for site which need to display the information to the user More...
 
const std::string & operator[] (unsigned int i) const
 for site which need to display the information to the user More...
 
std::string get_message (const std::string &sep) const
 concatenated messages and use the given separator between messages More...
 
virtual exception_baseclone () const =0
 create a new object of the same type and value of the object which clone() method is invoked More...
 

Protected Member Functions

void reset_first_message (const std::string &msg)
 for libthreader internal use only
 

Detailed Description

Pure virtual class parent of all webdar exceptions.

Over the different classes inherited from exception_base, all libthreadar exceptions contain a list of message that start from the source of the error followed by messages added by each try/catch context it occured in. You can access these messages by two ways:

You may ignore other features relative to exceptions used by libthreadar to report error while still able to completely use libthreadar.

However you are allowed to add new messages to the stack using push_message() and then rethrow the exception for propagation.

Why not concatenating string at each catch clause and propagating the exception? because depending on languagues some may prefer to present this nested informations another way than separating them with ':' from the less specific to the root cause

Definition at line 79 of file exceptions.hpp.

Constructor & Destructor Documentation

libthreadar::exception_base::exception_base ( const std::string &  x_msg)
inline

constructor

Note
used inside libthreadar only

Definition at line 85 of file exceptions.hpp.

Member Function Documentation

virtual exception_base* libthreadar::exception_base::clone ( ) const
pure virtual

create a new object of the same type and value of the object which clone() method is invoked

Note
this is true for pointer to inherited class, even if the pointer is of type exception_base the pointed to object will be of the same type of the inherited class

Implemented in libthreadar::exception_feature, libthreadar::exception_range, libthreadar::exception_system, libthreadar::exception_thread, libthreadar::exception_bug, and libthreadar::exception_memory.

std::string libthreadar::exception_base::get_message ( const std::string &  sep) const

concatenated messages and use the given separator between messages

Parameters
[in]sepis a string to insert between messages of the list (like for example ": ")
Returns
the resulting error message of the concatenation
const std::string& libthreadar::exception_base::operator[] ( unsigned int  i) const
inline

for site which need to display the information to the user

Parameters
[in]iis the index of the element of the list to return, it must be stricly lesser than size()
Returns
the requested element of the message list

Definition at line 102 of file exceptions.hpp.

unsigned int libthreadar::exception_base::size ( ) const
inline

for site which need to display the information to the user

Returns
the size of the message list

Definition at line 96 of file exceptions.hpp.


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