ql/errors.hpp File Reference


Detailed Description

Classes and functions for error handling.

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

Include dependency graph for errors.hpp:


Namespaces

namespace  QuantLib

Classes

class  Error
 Base error class. More...

Defines

#define QL_FAIL(message)
 throw an error (possibly with file and line information)
#define QL_ASSERT(condition, message)
 throw an error if the given condition is not verified
#define QL_REQUIRE(condition, message)
 throw an error if the given pre-condition is not verified
#define QL_ENSURE(condition, message)
 throw an error if the given post-condition is not verified

Define Documentation

#define QL_FAIL ( message   ) 

Value:

do { \
    std::ostringstream _ql_msg_stream; \
    _ql_msg_stream << message; \
    throw QuantLib::Error(__FILE__,__LINE__, \
                          BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} while (false)
throw an error (possibly with file and line information)

#define QL_ASSERT ( condition,
message   ) 

Value:

if (!(condition)) { \
    std::ostringstream _ql_msg_stream; \
    _ql_msg_stream << message; \
    throw QuantLib::Error(__FILE__,__LINE__, \
                          BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} else
throw an error if the given condition is not verified

#define QL_REQUIRE ( condition,
message   ) 

Value:

if (!(condition)) { \
    std::ostringstream _ql_msg_stream; \
    _ql_msg_stream << message; \
    throw QuantLib::Error(__FILE__,__LINE__, \
                          BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} else
throw an error if the given pre-condition is not verified

Examples:
DiscreteHedging.cpp, and swapvaluation.cpp.

#define QL_ENSURE ( condition,
message   ) 

Value:

if (!(condition)) { \
    std::ostringstream _ql_msg_stream; \
    _ql_msg_stream << message; \
    throw QuantLib::Error(__FILE__,__LINE__, \
                          BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
} else
throw an error if the given post-condition is not verified