wibble  1.1
Public Member Functions | Protected Attributes | List of all members
wibble::exception::System Class Reference

Base class for system exceptions. More...

#include <exception.h>

Inheritance diagram for wibble::exception::System:
Inheritance graph
[legend]
Collaboration diagram for wibble::exception::System:
Collaboration graph
[legend]

Public Member Functions

 System (const std::string &context) throw ()
 
 System (int code, const std::string &context) throw ()
 
virtual const char * type () const throw ()
 Get a string tag identifying the exception type. More...
 
virtual int code () const throw ()
 Get the system error code associated to the exception. More...
 
virtual std::string desc () const throw ()
 Get the description of the error code. More...
 
- Public Member Functions inherited from wibble::exception::Generic
 Generic () throw ()
 
 Generic (const std::string &context) throw ()
 
virtual ~Generic () throw ()
 
virtual const std::string & fullInfo () const throw ()
 Format in a string all available information about the exception. More...
 
virtual const char * what () const throw ()
 
- Public Member Functions inherited from wibble::exception::Context
 Context () throw ()
 
 Context (const std::string &context) throw ()
 
void addContext (const std::string &c) throw ()
 
std::string formatContext () const throw ()
 
const std::vector< std::string > & context () const throw ()
 

Protected Attributes

int m_errno
 
- Protected Attributes inherited from wibble::exception::Generic
std::string m_formatted
 
- Protected Attributes inherited from wibble::exception::Context
std::vector< std::string > m_context
 

Detailed Description

Base class for system exceptions.

This is the base class for exceptions that depend on system events, like exceptions on file or network I/O, on database access and so on. SystemExceptions introduces the keeping of an error code with an associated string description, and by defaults provides the textual description for Unix errno error codes. The exception context should be phrased like "doing X".

Example:

const char* fname = "foo.bar";
if ((fd = open(fname, O_RDONLY)) == -1)
// Should not throw SystemException, but a more specialized derived
// class like FileException
throw SystemException(errno, stringf::fmt("opening %s read-only", fname));

Constructor & Destructor Documentation

wibble::exception::System::System ( const std::string &  context)
throw (
)
wibble::exception::System::System ( int  code,
const std::string &  context 
)
throw (
)

Member Function Documentation

virtual int wibble::exception::System::code ( ) const
throw (
)
inlinevirtual

Get the system error code associated to the exception.

Referenced by TestException::system().

virtual std::string wibble::exception::System::desc ( ) const
throw (
)
virtual

Get the description of the error code.

Reimplemented from wibble::exception::Generic.

Reimplemented in wibble::exception::File.

Referenced by wibble::exception::File::desc().

virtual const char* wibble::exception::System::type ( ) const
throw (
)
inlinevirtual

Get a string tag identifying the exception type.

Reimplemented from wibble::exception::Generic.

Reimplemented in wibble::exception::File.

Member Data Documentation

int wibble::exception::System::m_errno
protected

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