IMP logo

exception.h File Reference

Exception definitions and assertions. More...

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.


Data Structures

class  IMP::Exception
 The general base class for IMP exceptions. More...
class  IMP::IndexException
 An exception for a request for an invalid member of a container. More...
struct  IMP::InternalException
 A general exception for an intenal error in IMP. More...
class  IMP::IOException
 An input/output exception. More...
class  IMP::ModelException
 An exception which is thrown when the Model has attributes with invalid values. More...
class  IMP::UsageException
 An exception for an invalid usage of IMP. More...
class  IMP::ValueException
 An exception for an invalid value being passed to IMP. More...

Namespaces

namespace  IMP
 The IMP kernel provides base classes and key shared functionality.

Detailed Description

Exception definitions and assertions.

Copyright 2007-2010 IMP Inventors. All rights reserved.


Define Documentation

#define IMP_CHECK_CODE ( expr   ) 

Only compile the code if checks are enabled.

For example

    IMP_CHECK_CODE({
        std::vector<Particle*> testp(input.begin(), input.end());
        std::sort(testp.begin(), testp.end());
        IMP_USAGE_CHECK(std::unique(testp.begin(), testp.end()) == testp.end(),
                        "Duplicate particles found in the input list.");
    });

#define IMP_FAILURE ( message   ) 

A runtime failure for IMP.

Parameters:
[in] message Failure message to write. This macro is used to provide nice error messages when there is an internal error in IMP. It causes an IMP::InternalException to be thrown.

#define IMP_IF_CHECK ( level   ) 

Execute the code block if a certain level checks are on.

The next code block (delimited by { }) is executed if get_check_level() <= level.

For example:

    IMP_CHECK_CODE(CHECK_USAGE) {
        std::vector<Particle*> testp(input.begin(), input.end());
        std::sort(testp.begin(), testp.end());
        IMP_USAGE_CHECK(std::unique(testp.begin(), testp.end()) == testp.end(),
                        "Duplicate particles found in the input list.");
    }

#define IMP_INTERNAL_CHECK ( expr,
message   ) 

An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.

Since it is a debug-only check and no attempt should be made to recover from it, the exception type cannot be specified.

For example:

    IMP_INTERNAL_CHECK((3.14-PI) < .01,
                       "PI is not close to 3.14. It is instead " << PI);

Note:
if the code is compiled with 'fast', or the check level is less than IMP::USAGE_AND_INTERNAL, the check is not performed. Do not use asserts as a shorthand to throw exceptions (throw the exception yourself); use them only to check for logic errors.
Parameters:
[in] expr The assertion expression.
[in] message Write this message if the assertion fails.

#define IMP_THROW ( message,
exception_name   ) 

Throw an exception with a message.

The exception thrown must inherit from Exception and not be UsageException or InternalException as those are reserved for disableable checks (the IMP_INTERNAL_CHECK() and IMP_USAGE_CHECK() macros).

    IMP_THROW("Could not open file " << file_name,
              IOException);

#define IMP_USAGE_CHECK ( expr,
message   ) 

A runtime test for incorrect usage of a class or method.

Parameters:
[in] expr The assertion expression.
[in] message Write this message if the assertion fails.
It should be used to check arguments to function. For example
    IMP_USAGE_CHECK(positive_argument >0,
                    "Argument positive_argument to function my_function "
                    << " must be positive. Instead got " << positive_argument);

Note:
if the build is 'fast', or the check level is less than IMP::USAGE, the check is not performed. Do not use these checks as a shorthand to throw necessary exceptions (throw the exception yourself); use them only to check for errors, such as inappropriate input.


Generated on Mon Mar 8 23:05:16 2010 for IMP by doxygen 1.5.8