exception.h File Reference

Header file declaring some exception types. More...

#include <cstring>
#include <exception>

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.

Namespaces

namespace  dlr
namespace  dlr::common

Classes

class  dlr::common::Exception
 Base class for all exceptions thrown from code in namespace dlr. More...
class  dlr::common::IOException
 This is an Exception class for errors in which the outside world is misbehaving. More...

Defines

#define DLR_THROW(exception, functionName, message)
 The DLR_THROW macro constructs an exception instance using the specified error message & function name, and automatically provides file name & line number arguments.
#define DLR_THROW2(exception, message)
 The DLR_THROW2 macro constructs an exception instance using the specified error message, and automatically provides file name & line number arguments.
#define DLR_THROW3(exception, functionName, message)
 The DLR_THROW3 macro is exactly equivalent to the DLR_THROW macro.
#define DLR_EXCEPTION_MESSAGE_LENGTH   512
 This macro to defines the maximum length of the exception internal error message string.
#define DLR_EXCEPTION_TRACE_MESSAGE_LENGTH   512
 This macro defines the maximum length of the string used to record trace information for each stack level.
#define DLR_EXCEPTION_TRACE_REQUIRED_STACK_LEVELS   16
 This macro defines the maximum number of stack levels for which to report trace information.
#define DLR_DECLARE_EXCEPTION_TYPE(ExceptionName, ParentName)
 This macro makes it easy to declare new exception types.

Functions

 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (IndexException, Exception)
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (LogicException, Exception)
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (NotImplementedException, Exception)
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (RunTimeException, Exception)
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (StateException, Exception)
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (ValueException, Exception)


Detailed Description

Header file declaring some exception types.

Copyright (c) 2003-2007, David LaRose, dlr@cs.cmu.edu See accompanying file, LICENSE.TXT, for details.

Revision
876
Date
2007-05-04 00:07:25 -0400 (Fri, 04 May 2007)

Definition in file exception.h.


Define Documentation

#define DLR_DECLARE_EXCEPTION_TYPE ( ExceptionName,
ParentName   ) 

This macro makes it easy to declare new exception types.

The point of the Exception class heirarchy is to encourage client code to derive its own exception classes. Unfortunately, there are several constructors to declare, which makes deriving exception subclasses a headache, so nobody does it. The maintainability hit we take by having a magic macro for declaring exception types is less than the maintainability hit we take by always throwing generic exceptions, so we bite the bullet and define a macro for subclassing exceptions. For example, if you needed some subclasss of dlr::IOException to communicate parsing failures in a file-parsing class, you might use it like this:

 DLR_DECLARE_EXCEPTION_TYPE(ParseException, dlr::IOException);
 DLR_DECLARE_EXCEPTION_TYPE(SyntaxException, ParseException);
 DLR_DECLARE_EXCEPTION_TYPE(MissingArgumentException, ParseException);

Parameters:
ExceptionName This argument is the name of the new exception class.
ParentName This argument is the name of the parent class. It can be set to dlr::Exception or to any class derived from dlr::Exception using the DLR_DECLARE_EXCEPTION_TYPE macro.

Definition at line 232 of file exception.h.

#define DLR_EXCEPTION_MESSAGE_LENGTH   512

This macro to defines the maximum length of the exception internal error message string.

That is, it defines how long the what() message can be.

Definition at line 171 of file exception.h.

Referenced by dlr::common::Exception::Exception(), and dlr::common::Exception::operator=().

#define DLR_EXCEPTION_TRACE_MESSAGE_LENGTH   512

This macro defines the maximum length of the string used to record trace information for each stack level.

If _DLRCOMMON_USE_TRACEABLE_ is defined, then sizeof(dlr::exception) will be slightly larger than (DLR_EXCEPTION_TRACE_MESSAGE_LENGTH * DLR_EXCEPTION_TRACE_REQUIRED_STACK_LEVELS).

WARNING: If you change the value of this macro, then the size of dlr::Exception will change, you must recompile dlr_libs with the new value or you'll have nasty linkage errors due to the size change.

Definition at line 187 of file exception.h.

Referenced by dlr::common::Exception::addTrace(), dlr::common::Exception::Exception(), and dlr::common::Exception::operator=().

#define DLR_EXCEPTION_TRACE_REQUIRED_STACK_LEVELS   16

This macro defines the maximum number of stack levels for which to report trace information.

Sizeof(dlr::exception) will be slightly larger than (DLR_EXCEPTION_TRACE_MESSAGE_LENGTH * DLR_EXCEPTION_TRACE_REQUIRED_STACK_LEVELS).

WARNING: If you change the value of this macro, then the size of dlr::Exception will change, you must recompile dlr_libs with the new value or you'll have nasty linkage errors due to this size change.

Definition at line 202 of file exception.h.

Referenced by dlr::common::Exception::addTrace(), dlr::common::Exception::Exception(), and dlr::common::Exception::operator=().

#define DLR_THROW ( exception,
functionName,
message   ) 

Value:

{ \
  throw exception(message, functionName, __FILE__, __LINE__); \
  }
The DLR_THROW macro constructs an exception instance using the specified error message & function name, and automatically provides file name & line number arguments.

You might use it like this:

DLR_THROW(dlr::IndexException, "myFunction(int)", "Argument value is out-of-bounds.");

Parameters:
exception This argument specifies the type of exception to throw.
functionName This argument specifies the name of the function from which the exception is being thrown.
message This argument specifies a C-style string describing the error.

Definition at line 118 of file exception.h.

#define DLR_THROW2 ( exception,
message   ) 

Value:

{ \
  throw exception(message, __FILE__, __LINE__); \
  }
The DLR_THROW2 macro constructs an exception instance using the specified error message, and automatically provides file name & line number arguments.

It differs from DLR_THROW in that the function name is not specified.

DLR_THROW(dlr::IndexException, "Bad state in graphics hardware.");

Parameters:
exception This argument specifies the type of exception to throw.
message This argument specifies a C-style string describing the error.

Definition at line 137 of file exception.h.

#define DLR_THROW3 ( exception,
functionName,
message   ) 

Value:

{ \
  throw exception(message, functionName, __FILE__, __LINE__); \
  }
The DLR_THROW3 macro is exactly equivalent to the DLR_THROW macro.

You might use it like this:

DLR_THROW3(dlr::IndexException, "myFunction(int)", "Argument value is out-of-bounds.");

Parameters:
exception This argument specifies the type of exception to throw.
functionName This argument specifies the name of the function from which the exception is being thrown.
message This argument specifies a C-style string describing the error.

Definition at line 158 of file exception.h.


Generated on Sat Dec 29 04:08:11 2007 for dlrCommon Utility Library by  doxygen 1.5.4