Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Exception.hpp File Reference

#include "common_headers.hpp"

Go to the source code of this file.

Compounds

class  Exception

Defines

#define LEMUR_MAKESTR(x)   # x
#define LEMUR_ABORT(e)   { std::cerr << e.what() << std::endl; exit(-1); }
#define LEMUR_THROW_LINE(code, text, file, line)
#define LEMUR_THROW(code, text)   LEMUR_THROW_LINE(code, text, __FILE__, __LINE__)
#define LEMUR_RETHROW_LINE(e, text, file, line)
#define LEMUR_RETHROW(e, text)   LEMUR_RETHROW_LINE(e, text, __FILE__, __LINE__)
#define LEMUR_GENERIC_ERROR   ((LemurErrorType)0xFFFFFFFF)
#define LEMUR_MISSING_PARAMETER_ERROR   ((LemurErrorType)0xFFFFFFFE)
#define LEMUR_PARSE_ERROR   ((LemurErrorType)0xFFFFFFFD)
#define LEMUR_KEYFILE_IO_ERROR   ((LemurErrorType)0xFFFFFFFC)
#define LEMUR_IO_ERROR   ((LemurErrorType)0xFFFFFFFB)
#define LEMUR_RUNTIME_ERROR   ((LemurErrorType)0xFFFFFFFA)
#define LEMUR_NETWORK_ERROR   ((LemurErrorType)0xFFFFFFF9)

Typedefs

typedef unsigned long LemurErrorType
 Default Exception class.


Define Documentation

#define LEMUR_ABORT      { std::cerr << e.what() << std::endl; exit(-1); }
 

#define LEMUR_GENERIC_ERROR   ((LemurErrorType)0xFFFFFFFF)
 

#define LEMUR_IO_ERROR   ((LemurErrorType)0xFFFFFFFB)
 

#define LEMUR_KEYFILE_IO_ERROR   ((LemurErrorType)0xFFFFFFFC)
 

#define LEMUR_MAKESTR      # x
 

#define LEMUR_MISSING_PARAMETER_ERROR   ((LemurErrorType)0xFFFFFFFE)
 

#define LEMUR_NETWORK_ERROR   ((LemurErrorType)0xFFFFFFF9)
 

#define LEMUR_PARSE_ERROR   ((LemurErrorType)0xFFFFFFFD)
 

#define LEMUR_RETHROW e,
text       LEMUR_RETHROW_LINE(e, text, __FILE__, __LINE__)
 

#define LEMUR_RETHROW_LINE e,
text,
file,
line   
 

Value:

throw Exception( file, LEMUR_MAKESTR(line), \
                                                   (text), (e) )

#define LEMUR_RUNTIME_ERROR   ((LemurErrorType)0xFFFFFFFA)
 

#define LEMUR_THROW code,
text       LEMUR_THROW_LINE(code, text, __FILE__, __LINE__)
 

#define LEMUR_THROW_LINE code,
text,
file,
line   
 

Value:

throw Exception( file, LEMUR_MAKESTR(line), \
                                                    std::string() + text, (code) )


Typedef Documentation

typedef unsigned long LemurErrorType
 

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.


Generated on Fri Jul 2 16:25:38 2004 for Lemur Toolkit by doxygen1.2.18