Tagcoll::Exception Class Reference

Base class for all exceptions. More...

#include <Exception.h>

Inheritance diagram for Tagcoll::Exception:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Exception () throw ()
virtual ~Exception () throw ()
virtual const char * type () const throw ()
 Get a string tag identifying the exception type.
virtual std::string desc () const throw ()
 Get a string describing what happened that threw the exception.
virtual const char * what () const throw ()
 Get a string describing what happened that threw the exception, STL style.

Detailed Description

Base class for all exceptions.

This is 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.

The base class interface provides an interface to get a (hopefully detailed) textual description of the exception, and a tag describing the type of exception. Further functionality will be provided by subclassers

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


Constructor & Destructor Documentation

Tagcoll::Exception::Exception (  )  throw () [inline]

virtual Tagcoll::Exception::~Exception (  )  throw () [inline, virtual]


Member Function Documentation

virtual std::string Tagcoll::Exception::desc (  )  const throw () [inline, virtual]

Get a string describing what happened that threw the exception.

Reimplemented in Tagcoll::ContextException, Tagcoll::OutOfRangeException, Tagcoll::ValOutOfRangeException< C >, Tagcoll::SystemException, and Tagcoll::ParserException.

virtual const char* Tagcoll::Exception::type (  )  const throw () [inline, virtual]

Get a string tag identifying the exception type.

Reimplemented in Tagcoll::commandline::BadOption, Tagcoll::ContextException, Tagcoll::NotFoundException, Tagcoll::InterruptedException, Tagcoll::WaitInterruptedException, Tagcoll::ConsistencyCheckException, Tagcoll::OutOfRangeException, Tagcoll::ValOutOfRangeException< C >, Tagcoll::SystemException, Tagcoll::FileException, Tagcoll::ParserException, and Tagcoll::ParserInputException.

virtual const char* Tagcoll::Exception::what (  )  const throw () [inline, virtual]

Get a string describing what happened that threw the exception, STL style.


The documentation for this class was generated from the following file:
Generated on Sat Aug 19 01:08:06 2006 for libtagcoll by  doxygen 1.4.7