QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
errors.hpp File Reference

Classes and functions for error handling. More...

#include <ql/qldefines.hpp>
#include <ql/shared_ptr.hpp>
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
#include <exception>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

class  Error
 Base error class. More...
 

Namespaces

namespace  QuantLib
 

Macros

#define QL_MULTILINE_FAILURE_BEGIN   do {
 
#define QL_MULTILINE_FAILURE_END   } while(false)
 
#define QL_MULTILINE_ASSERTION_BEGIN   do {
 
#define QL_MULTILINE_ASSERTION_END   } while(false)
 
#define QL_FAIL(message)
 throw an error (possibly with file and line information) More...
 
#define QL_ASSERT(condition, message)
 throw an error if the given condition is not verified More...
 
#define QL_REQUIRE(condition, message)
 throw an error if the given pre-condition is not verified More...
 
#define QL_ENSURE(condition, message)
 throw an error if the given post-condition is not verified More...
 

Detailed Description

Classes and functions for error handling.

Definition in file errors.hpp.

Macro Definition Documentation

◆ QL_MULTILINE_FAILURE_BEGIN

#define QL_MULTILINE_FAILURE_BEGIN   do {

Definition at line 57 of file errors.hpp.

◆ QL_MULTILINE_FAILURE_END

#define QL_MULTILINE_FAILURE_END   } while(false)

Definition at line 69 of file errors.hpp.

◆ QL_MULTILINE_ASSERTION_BEGIN

#define QL_MULTILINE_ASSERTION_BEGIN   do {

Definition at line 73 of file errors.hpp.

◆ QL_MULTILINE_ASSERTION_END

#define QL_MULTILINE_ASSERTION_END   } while(false)

Definition at line 85 of file errors.hpp.

◆ QL_FAIL

#define QL_FAIL (   message)
Value:
QL_MULTILINE_FAILURE_BEGIN \
std::ostringstream _ql_msg_stream; \
_ql_msg_stream << message; \
throw QuantLib::Error(__FILE__,__LINE__, \
BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
Base error class.
Definition: errors.hpp:39
#define QL_MULTILINE_FAILURE_END
Definition: errors.hpp:69

throw an error (possibly with file and line information)

Definition at line 92 of file errors.hpp.

◆ QL_ASSERT

#define QL_ASSERT (   condition,
  message 
)
Value:
QL_MULTILINE_ASSERTION_BEGIN \
if (!(condition)) { \
std::ostringstream _ql_msg_stream; \
_ql_msg_stream << message; \
throw QuantLib::Error(__FILE__,__LINE__, \
BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} \
#define QL_MULTILINE_ASSERTION_END
Definition: errors.hpp:85

throw an error if the given condition is not verified

Definition at line 104 of file errors.hpp.

◆ QL_REQUIRE

#define QL_REQUIRE (   condition,
  message 
)
Value:
QL_MULTILINE_ASSERTION_BEGIN \
if (!(condition)) { \
std::ostringstream _ql_msg_stream; \
_ql_msg_stream << message; \
throw QuantLib::Error(__FILE__,__LINE__, \
BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} \

throw an error if the given pre-condition is not verified

Examples
DiscreteHedging.cpp, FittedBondCurve.cpp, GlobalOptimizer.cpp, and MulticurveBootstrapping.cpp.

Definition at line 117 of file errors.hpp.

◆ QL_ENSURE

#define QL_ENSURE (   condition,
  message 
)
Value:
QL_MULTILINE_ASSERTION_BEGIN \
if (!(condition)) { \
std::ostringstream _ql_msg_stream; \
_ql_msg_stream << message; \
throw QuantLib::Error(__FILE__,__LINE__, \
BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} \

throw an error if the given post-condition is not verified

Definition at line 130 of file errors.hpp.