dlrCommon/exception.h File Reference

Header file declaring some exception types. More...

#include <cstring>
#include <exception>

Include dependency graph for dlrCommon/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)
 This is an Exception class for errors in which an array index or similar argument is out of bounds.
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (LogicException, Exception)
 This is an Exception class for errors which could have been caught at compile time.
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (NotImplementedException, Exception)
 This type of Exception is thrown when a piece of code has not been written, and the developer had the foresight to document its non-existence.
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (RunTimeException, Exception)
 This exception is thrown when an error occurs which could not have been anticipated at compile time, and for which ValueException, IOException, etc., are not appropriate.
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (StateException, Exception)
 This exception is thrown when the internal state of a class is inconsistent, or when the calling environment interacts with a class in a way which is inconsistent with its internal state.
 dlr::common::DLR_DECLARE_EXCEPTION_TYPE (ValueException, Exception)
 This exception is thrown when the argument to a function has and inappropriate value, and when a more specific exception is not appropriate.


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 dlrCommon/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 235 of file dlrCommon/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 174 of file dlrCommon/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 190 of file dlrCommon/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 205 of file dlrCommon/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 121 of file dlrCommon/exception.h.

Referenced by dlr::utilities::OptionParser::addOption(), dlr::utilities::OptionParser::addOptionWithValue(), dlr::computerVision::applyCanny(), dlr::computerVision::applySobelX(), dlr::computerVision::applySobelY(), dlr::computerVision::associateColorComponents(), dlr::thread::BroadcastQueue< Type >::BroadcastQueue(), dlr::numeric::Stencil2D< Type, Size >::checkBounds(), dlr::numeric::Array3D< Type >::checkDimension(), dlr::numeric::Array2D< Type >::checkDimension(), dlr::numeric::Array1D< Type >::checkDimension(), dlr::numeric::BSpline< Type >::computeBasisFunction(), dlr::utilities::convertString(), dlr::numeric::Array3D< Type >::copy(), dlr::numeric::Array2D< Type >::copy(), dlr::thread::Monitor::copyOther(), dlr::numeric::correlate(), dlr::numeric::correlate1D(), dlr::numeric::correlate2D(), dlr::computerVision::dissociateColorComponents(), dlr::thread::DistributionQueue< Type >::DistributionQueue(), dlr::geometry::findIntersect(), dlr::numeric::IEEEFloat32::getByte(), dlr::numeric::BSpline< Type >::getCoefficientMatrices(), dlr::utilities::OptionParser::getCount(), dlr::computerVision::getGaussianKernel(), dlr::computerVision::getHistogram(), dlr::numeric::BSpline< Type >::getMaximumSValue(), dlr::numeric::BSpline< Type >::getMinimumSValue(), dlr::numeric::BSpline< Type >::getSpanNumber(), dlr::utilities::OptionParser::getValue(), dlr::computerVision::OpticalFlow< Format >::ignoreArea(), dlr::numeric::Transform3D::invert(), dlr::numeric::Transform2D::invert(), dlr::thread::ThreadFunctor::join(), dlr::portability::listDirectory(), dlr::thread::BroadcastQueue< Type >::lockBack(), dlr::numeric::matrixMultiply(), dlr::numeric::newtonRaphson(), dlr::computerVision::nonMaximumSuppress(), dlr::numeric::operator *(), dlr::numeric::Array3D< Type >::operator *=(), dlr::numeric::Array2D< Type >::operator *=(), dlr::numeric::Transform3DTo2D::operator()(), dlr::numeric::Transform3D::operator()(), dlr::numeric::operator+(), dlr::numeric::Array3D< Type >::operator+=(), dlr::numeric::Array2D< Type >::operator+=(), dlr::numeric::operator-(), dlr::numeric::Array3D< Type >::operator-=(), dlr::numeric::Array2D< Type >::operator-=(), dlr::numeric::operator/(), dlr::numeric::Vector3D::operator/=(), dlr::numeric::Vector2D::operator/=(), dlr::numeric::Index2D::operator/=(), dlr::numeric::Array3D< Type >::operator/=(), dlr::numeric::Array2D< Type >::operator/=(), dlr::numeric::operator<<(), dlr::thread::ThreadFunctor::operator=(), dlr::thread::Monitor::operator=(), dlr::utilities::OptionParser::parseCommandLine(), dlr::thread::BroadcastQueue< Type >::popBack(), dlr::thread::DistributionQueue< Type >::pushFront(), dlr::thread::BroadcastQueue< Type >::pushFront(), dlr::computerVision::readPGM16(), dlr::computerVision::readPGM8(), dlr::computerVision::readPPM8(), dlr::computerVision::registerPoints3D(), dlr::numeric::Array3D< Type >::reshape(), dlr::numeric::Array2D< Type >::reshape(), dlr::thread::ThreadFunctor::run(), dlr::optimization::OptimizerNelderMead< Functor >::run(), dlr::computerVision::Snake::run(), dlr::computerVision::Snake::runOneIteration(), dlr::numeric::BSpline< Type >::setControlPoints(), dlr::computerVision::Snake::setCornerAdditionAngle(), dlr::computerVision::Snake::setCornerDeletionAngle(), dlr::utilities::Date::setISODate(), dlr::numeric::BSpline< Type >::setKnotMultiplicities(), dlr::numeric::BSpline< Type >::setNodePositions(), dlr::numeric::Stencil2D< Type, Size >::setPattern(), dlr::numeric::Transform3D::setValue(), dlr::numeric::Transform2D::setValue(), dlr::numeric::Array3D< Type >::shape(), dlr::numeric::Array2D< Type >::shape(), dlr::numeric::skewSymmetric(), dlr::numeric::Stencil2D< Type, Size >::Stencil2D(), dlr::thread::BroadcastQueue< Type >::synchronize(), dlr::thread::BroadcastQueue< Type >::synchronizeQuorum(), dlr::numeric::Transform2D::Transform2D(), dlr::numeric::Transform3D::Transform3D(), dlr::numeric::Transform3DTo2D::Transform3DTo2D(), dlr::numeric::Transform3DTo2D::value(), dlr::numeric::Transform3D::value(), dlr::utilities::writePGM(), dlr::computerVision::writePGM16(), dlr::computerVision::writePGM8(), dlr::utilities::writePPM(), and dlr::computerVision::writePPM8().

#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 140 of file dlrCommon/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 161 of file dlrCommon/exception.h.

Referenced by dlr::GaussianDistribution< VectorType >::addSample(), dlr::numeric::AmanatidesWoo2D< ARRAY2D >::AmanatidesWoo2D(), dlr::numeric::AmanatidesWoo3D< ARRAY3D >::AmanatidesWoo3D(), dlr::numeric::Array1D< Type >::Array1D(), dlr::numeric::Array2D< Type >::Array2D(), dlr::numeric::Array3D< Type >::Array3D(), dlr::numeric::axisMaximum(), dlr::numeric::axisMinimum(), dlr::numeric::axisSum(), dlr::numeric::compress(), dlr::optimization::contextSensitiveScale(), dlr::numeric::Array3D< Type >::copy(), dlr::numeric::Array2D< Type >::copy(), dlr::numeric::Array1D< Type >::copy(), dlr::linearAlgebra::determinant(), dlr::optimization::OptimizerBFGS< Functor >::doBfgs(), dlr::numeric::dot(), dlr::optimization::dotArgumentType(), dlr::linearAlgebra::eigenvaluesSymmetric(), dlr::linearAlgebra::eigenvectorsSymmetric(), dlr::optimization::GradientFunction< Functor >::GradientFunction(), dlr::linearAlgebra::inverse(), dlr::numeric::NumericTraits< Type >::isIntegral(), dlr::linearAlgebra::linearFit(), dlr::linearAlgebra::linearLeastSquares(), dlr::linearAlgebra::linearSolveInPlace(), dlr::linearAlgebra::linearSolveTridiagonal(), dlr::optimization::matrixMultiplyArgumentType(), dlr::numeric::maximum(), dlr::numeric::mean(), dlr::numeric::minimum(), dlr::numeric::Array1D< Type >::operator *=(), dlr::numeric::Transform2D::operator()(), dlr::GaussianDistribution< VectorType >::operator()(), dlr::numeric::Array1D< Type >::operator+=(), dlr::numeric::Array1D< Type >::operator-=(), dlr::numeric::Array1D< Type >::operator/=(), dlr::numeric::range(), dlr::optimization::OptimizerLM< Functor >::run(), dlr::optimization::OptimizerLineSearch< Functor >::run(), dlr::optimization::OptimizerBFGS< Functor >::run(), dlr::optimization::OptimizerLineSearch< Functor >::setInitialStep(), dlr::GaussianDistribution< VectorType >::setSampleData(), dlr::linearAlgebra::singularValueDecomposition(), dlr::linearAlgebra::singularValueDecompositionSimple(), dlr::linearAlgebra::singularValues(), and dlr::numeric::Transform2D::value().


Generated on Mon Jul 9 20:34:07 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2