Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

lemur::api::Exception Class Reference

Default Exception class. More...

#include <Exception.hpp>

List of all members.

Public Member Functions

 Exception (const char *throwerString="unknown thrower", const char *whatString="unknown exception")
 Exception (const std::string &whoString, int whereLine, const std::string &whatString, LemurErrorType code)
 Exception (const std::string &whoString, int whereLine, const std::string &whatString, const Exception &inner)
 ~Exception ()
void writeMessage (std::ostream &os=std::cerr)
const std::string & what () const
LemurErrorType code () const

Private Attributes

std::string _what
LemurErrorType _code


Detailed Description

Default Exception class.

This is the base Exception class that all other exceptions should inherit from. Some guidelines for using Exception:

(1) Define your main function as "int AppMain(int argc, char *argv[])" rather than the normal "main" function. (2) Use the LEMUR_THROW and LEMUR_RETHROW macros to throw the exception, and to pass it along to the next level's handler, respectively. To use LEMUR_THROW, include the appropriate Lemur error code, and whatever string description you want. File and line information are automatically included. The error code can be from the standard Lemur list (see below). (3) Here's an example of how you might use LEMUR_THROW to generate an exception, and LEMUR_RETHROW to pass it along to the next handler.

try { ... ... // within the index open routine, this exception might be thrown: LEMUR_THROW(LEMUR_IO_ERROR, "The index file does not exist"); } catch (Exception &ex) { LEMUR_RETHROW(ex, "Could not start retrieval program."); }

In general, consistent use of LEMUR_THROW and LEMUR_RETHROW will result in a nested series of exception messages, showing successively lower levels of exception information, allowing easy tracing of the failure path.

(4) If the exception is not caught in the application, it will be caught be the main function in the lemur toolkit. The default exception handler prints the following message on stderr and terminates the program.

Exception FileName.cpp(#linenum): The index file does not exist Program aborted due to exception

(5) You can define more specific exceptions by subclassing Exception. All exceptions will be caught by the default main function if not caught by an application.


Constructor & Destructor Documentation

lemur::api::Exception::Exception const char *  throwerString = " unknown thrower",
const char *  whatString = "unknown exception"
[inline]
 

lemur::api::Exception::Exception const std::string &  whoString,
int  whereLine,
const std::string &  whatString,
LemurErrorType  code
[inline]
 

lemur::api::Exception::Exception const std::string &  whoString,
int  whereLine,
const std::string &  whatString,
const Exception inner
[inline]
 

lemur::api::Exception::~Exception  )  [inline]
 


Member Function Documentation

LemurErrorType lemur::api::Exception::code  )  const [inline]
 

const std::string& lemur::api::Exception::what  )  const [inline]
 

void lemur::api::Exception::writeMessage std::ostream &  os = std::cerr  )  [inline]
 


Member Data Documentation

LemurErrorType lemur::api::Exception::_code [private]
 

std::string lemur::api::Exception::_what [private]
 


The documentation for this class was generated from the following file:
Generated on Tue Jun 15 11:03:04 2010 for Lemur by doxygen 1.3.4