Exception.h File Reference

#include <string>
#include <buffy/stringf.h>

Go to the source code of this file.

Classes

class  InstallUnexpected
 Install an unexpected handler for the duration of its scope. More...
class  Exception
 This is the base class for all exceptions used in the system. More...
class  ContextException
 Exception with a description of the throwing context. More...
class  InterruptedException
 It is a direct child of ContextException, and has the very same semantics. More...
class  WaitInterruptedException
 It is a direct child of InterruptedException, and has the very same semantics. More...
class  ConsistencyCheckException
 It is a direct child of ContextException, and has the very same semantics. More...
class  OutOfRangeException
class  ValOutOfRangeException< C >
 This exception is to be thrown when an index checking fails, providing informations on the acceptable index range and on the offending value. More...
class  SystemException
 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. More...
class  FileException
 It is a direct child of SystemException, and has the very same semantics. More...

Functions

void DefaultUnexpected ()
 This is an unexpected handler provided by the library.


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);
        }

Function Documentation

void DefaultUnexpected  ) 
 

This is an unexpected handler provided by the library.

It prints to stderr a stack trace and all possible available informations about the escaped exception.

To have the function names in the stack trace, the executables need to be linked using the -rdynamic flag.


Generated on Wed Nov 30 18:18:30 2005 for libbuffy by  doxygen 1.4.5