libpnicore
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends
pni::core::exception Class Reference

Exceptions base class. More...

#include <exceptions.hpp>

Inheritance diagram for pni::core::exception:
pni::core::cli_argument_error pni::core::cli_error pni::core::cli_help_request pni::core::cli_option_error pni::core::file_error pni::core::index_error pni::core::iterator_error pni::core::key_error pni::core::memory_allocation_error pni::core::memory_not_allocated_error pni::core::not_implemented_error pni::core::range_error pni::core::shape_mismatch_error pni::core::size_mismatch_error pni::core::type_error pni::core::value_error

Public Types

typedef std::list
< exception_record >
::const_iterator 
const_iterator
 const iterator over the error record
 

Public Member Functions

 exception ()
 default constructor
 
 exception (const string &n)
 constructor More...
 
 exception (const string &n, const exception_record &rec)
 constructor More...
 
 exception (const string &n, const exception_record &rec, const string &d)
 constructor More...
 
virtual ~exception () throw ()
 virtual destructor
 
void name (const std::string &name)
 set the exception name More...
 
const stringname () const
 get the exceptions name More...
 
void append (const exception_record &n)
 add a new issuer More...
 
void description (const std::string &desc)
 set exception desccription More...
 
const stringdescription () const
 get the exceptions description More...
 
const_iterator begin () const
 get iterator to first error record More...
 
const_iterator end () const
 get iterator to the last error record More...
 

Protected Member Functions

std::ostream & print (std::ostream &o) const
 ouptut method More...
 

Private Attributes

string _name
 name of the exception
 
string _description
 description of the error occured
 
std::list< exception_record_records
 exception records
 

Friends

std::ostream & operator<< (std::ostream &, const exception &)
 output operator for exceptions
 

Detailed Description

This is the base class for all exceptions used in this library.

Constructor & Destructor Documentation

pni::core::exception::exception ( const string n)
Parameters
nname of the exception
pni::core::exception::exception ( const string n,
const exception_record rec 
)
Parameters
nname of the exception
recException record of the initial location where the error occured
pni::core::exception::exception ( const string n,
const exception_record rec,
const string d 
)
Parameters
nname of the exception
recexception record describing the location of the first occurrence of the error
ddescription of the exception

Member Function Documentation

void pni::core::exception::append ( const exception_record n)
inline

Use this method to add a new issuer in the case that the exception is re-thrown by an other function or class method.

...
catch(exception &error)
{
error.append(EXCEPTION_RECORD);
throw error;
}

With this a particular exception can be traced througout the entire code.

Parameters
nexception_record to append
const_iterator pni::core::exception::begin ( ) const
inline

Return get a const iterator to the first error record in the class.

Returns
iterator to first exception record
void pni::core::exception::description ( const std::string &  desc)
inline
Parameters
descdescription of the exception
const string& pni::core::exception::description ( ) const
inline
Returns
reference to the string object with the exceptions description
const_iterator pni::core::exception::end ( ) const
inline

Return a const iterator pointing to the last+1 element in the exception record list.

Returns
iterator to last+1 exception record
void pni::core::exception::name ( const std::string &  name)
inline
Parameters
nameexception name
const string& pni::core::exception::name ( ) const
inline
Returns
reference to the string object holding the name
std::ostream& pni::core::exception::print ( std::ostream &  o) const
protected

Protected method to be used by derived classes for implementing exception printing to std::out.

Parameters
oreference to the ouptput stream
Returns
output stream

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