MADNESS  0.10.1
Classes | Namespaces | Macros | Functions
madness_exception.h File Reference

Defines madness::MadnessException for exception handling. More...

#include <cstdlib>
#include <iosfwd>
#include <exception>
#include <madness/madness_config.h>
Include dependency graph for madness_exception.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  madness::MadnessException
 Base class for exceptions thrown in MADNESS. More...
 

Namespaces

 madness
 File holds all helper structures necessary for the CC_Operator and CC2 class.
 

Macros

#define MADNESS_ASSERT(condition)
 Assert a condition that should be free of side-effects since in release builds this might be a no-op. More...
 
#define MADNESS_ASSERT_NOEXCEPT(condition)
 Same as MADNESS_ASSERT , but never throws. More...
 
#define MADNESS_CHECK(condition)
 Check a condition — even in a release build the condition is always evaluated so it can have side effects. More...
 
#define MADNESS_CHECK(condition)
 Check a condition — even in a release build the condition is always evaluated so it can have side effects. More...
 
#define MADNESS_CHECK_THROW(condition, msg)
 Check a condition — even in a release build the condition is always evaluated so it can have side effects. More...
 
#define MADNESS_CHECK_THROW(condition, msg)
 Check a condition — even in a release build the condition is always evaluated so it can have side effects. More...
 
#define MADNESS_DISPLAY_EXCEPTION_BREAK_MESSAGE   1
 Display the exception break message unless otherwise specified. More...
 
#define MADNESS_EXCEPTION(msg, value)
 Macro for throwing a MADNESS exception. More...
 

Functions

void madness::exception_break (bool message)
 This function is executed just before a MadnessException is thrown. More...
 
std::ostream & madness::operator<< (std::ostream &out, const MadnessException &e)
 Enables easy printing of a MadnessException. More...
 

Detailed Description

Defines madness::MadnessException for exception handling.

By default, the MADNESS_ASSERT macro throws a madness::MadnessException. Configure options can specify other behaviors: MADNESS_ASSERT can be

Macro Definition Documentation

◆ MADNESS_ASSERT

#define MADNESS_ASSERT (   condition)

Assert a condition that should be free of side-effects since in release builds this might be a no-op.

Depending on the configuration, one of the following happens if condition is false:

  • a madness::MadnessException is thrown.
  • assert(condition) is called.
  • execution is aborted.
  • nothing.
    Parameters
    [in]conditionThe condition to be asserted.

◆ MADNESS_ASSERT_NOEXCEPT

#define MADNESS_ASSERT_NOEXCEPT (   condition)

Same as MADNESS_ASSERT , but never throws.

Behaves like MADNESS_ASSERT, except when the latter throws madness::MadnessException this aborts

Parameters
[in]conditionThe condition to be asserted.

◆ MADNESS_CHECK [1/2]

#define MADNESS_CHECK (   condition)

Check a condition — even in a release build the condition is always evaluated so it can have side effects.

Depending on the configuration, one of the following happens if condition is false:

◆ MADNESS_CHECK [2/2]

#define MADNESS_CHECK (   condition)
Value:
do { \
if (!(condition)) { \
throw madness::MadnessException("MADNESS CHECK FAILED: " , \
(#condition),0,__LINE__,__FUNCTION__,__FILE__); \
} \
} while (0)
Base class for exceptions thrown in MADNESS.
Definition: madness_exception.h:66
#define MADNESS_DISPLAY_EXCEPTION_BREAK_MESSAGE
Display the exception break message unless otherwise specified.
Definition: madness_exception.h:58
void exception_break(bool message)
This function is executed just before a MadnessException is thrown.
Definition: madness_exception.cc:59

Check a condition — even in a release build the condition is always evaluated so it can have side effects.

Depending on the configuration, one of the following happens if condition is false:

◆ MADNESS_CHECK_THROW [1/2]

#define MADNESS_CHECK_THROW (   condition,
  msg 
)

Check a condition — even in a release build the condition is always evaluated so it can have side effects.

will always throw a madness::MadnessException, but will not print to stderr

Parameters
[in]conditionThe condition to be checked.
[in]msgThe message to be printed

◆ MADNESS_CHECK_THROW [2/2]

#define MADNESS_CHECK_THROW (   condition,
  msg 
)
Value:
do { \
if (!(condition)) { \
throw madness::MadnessException(msg, (#condition),0,__LINE__,__FUNCTION__,__FILE__); \
} \
} while (0)

Check a condition — even in a release build the condition is always evaluated so it can have side effects.

will always throw a madness::MadnessException, but will not print to stderr

Parameters
[in]conditionThe condition to be checked.
[in]msgThe message to be printed

◆ MADNESS_DISPLAY_EXCEPTION_BREAK_MESSAGE

#define MADNESS_DISPLAY_EXCEPTION_BREAK_MESSAGE   1

Display the exception break message unless otherwise specified.

◆ MADNESS_EXCEPTION

#define MADNESS_EXCEPTION (   msg,
  value 
)
Value:
{ \
throw madness::MadnessException(msg,0,value,__LINE__,__FUNCTION__,__FILE__); \
}

Macro for throwing a MADNESS exception.

Exceptions
Amadness::MadnessException.
Parameters
[in]msgThe error message.
[in]valueThe value associated with the exception.