wibble  1.1
Classes | Namespaces | Constant Groups | Functions
exception.h File Reference
#include <wibble/test.h>
#include <exception>
#include <typeinfo>
#include <string>
#include <sstream>
#include <iterator>
#include <vector>
Include dependency graph for exception.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  wibble::exception::InstallUnexpected
 Install an unexpected handler for the duration of its scope. More...
 
struct  wibble::exception::AddContext
 
class  wibble::exception::Context
 Store context information for an exception. More...
 
class  wibble::exception::Generic
 Base class for all exceptions. More...
 
class  wibble::exception::Interrupted
 Exception thrown when some long event is interrupted by an external event (like a system call being interrupted by a signal) More...
 
class  wibble::exception::WaitInterrupted
 Exception thrown when some system wait is interrupted by a signal. More...
 
class  wibble::exception::Consistency
 Exception thrown when some consistency check fails. More...
 
struct  wibble::exception::BadCast
 
struct  wibble::exception::BadCastExt< From, To >
 
class  wibble::exception::OutOfRange
 Exception thrown when some value is out of range. More...
 
class  wibble::exception::ValOutOfRange< C >
 Exception thrown when index checking fails. More...
 
class  wibble::exception::System
 Base class for system exceptions. More...
 
class  wibble::exception::File
 Base class for exceptions for file I/O. More...
 

Namespaces

 wibble
 
 wibble::exception
 

Constant Groups

 wibble
 
 wibble::exception
 

Functions

void wibble::exception::DefaultUnexpected ()
 Basic unexpected handler. More...
 

Detailed Description

This file provides the root of the exception hierarchy. The goal of this hierarchy is to provide the most possible information on what caused the exception at the least possible cost for the programmer.

Every exception is the descendent of Exception that, in turn, extends the std::exception class of the STL.

Further descendents of Exception add functionality and automatisms to error message generation:

Example exception raising:

void MyFile::open(const char* fname) throw (FileException)
{
if ((fd = open(fname, O_RDONLY)) == -1)
throw FileException(errno, stringf::fmt("opening %s read-only", fname));
}

Example exception catching:

try {
myfile.open("/tmp/foo");
} catch (FileException& e) {
fprintf(stderr, "%.*s: aborting.\n", PFSTR(e.toString()));
exit(1);
}