libDAI
Public Types | Public Member Functions | Private Attributes | Static Private Attributes
dai::Exception Class Reference

Error handling in libDAI is done by throwing an instance of the Exception class. More...

#include <dai/exceptions.h>

Inherits std::runtime_error.

List of all members.

Public Types

enum  Code {
  NOT_IMPLEMENTED, ASSERTION_FAILED, IMPOSSIBLE_TYPECAST, OBJECT_NOT_FOUND,
  BELIEF_NOT_AVAILABLE, UNKNOWN_ENUM_VALUE, UNKNOWN_DAI_ALGORITHM, UNKNOWN_PARAMETER_ESTIMATION_METHOD,
  UNKNOWN_PROPERTY_TYPE, UNKNOWN_PROPERTY, MALFORMED_PROPERTY, NOT_ALL_PROPERTIES_SPECIFIED,
  INVALID_ALIAS, CANNOT_READ_FILE, CANNOT_WRITE_FILE, INVALID_FACTORGRAPH_FILE,
  INVALID_EVIDENCE_FILE, INVALID_EMALG_FILE, NOT_NORMALIZABLE, MULTIPLE_UNDO,
  FACTORGRAPH_NOT_CONNECTED, INTERNAL_ERROR, RUNTIME_ERROR, OUT_OF_MEMORY,
  NUM_ERRORS
}
 Enumeration of exceptions used in libDAI. More...

Public Member Functions

 Exception (Code code, const char *filename, const char *function, const char *line, const std::string &detailedMsg)
 Constructor.
 ~Exception () throw ()
 Destructor.
Code getCode () const
 Returns error code of this exception.
Code code () const
 Returns error code of this exception.
const std::string & getMsg () const
 Returns short error message of this exception.
const std::string & getDetailedMsg () const
 Returns detailed error message of this exception.
const std::string & getFilename () const
 Returns filename where this exception was thrown.
const std::string & getFunction () const
 Returns function name in which this exception was thrown.
const std::string & getLine () const
 Returns line number where this exception was thrown.
const std::string & message (const Code c) const
 Returns error message corresponding to an error code.

Private Attributes

Code _errorcode
 Contains the error code of this exception.
std::string _detailedMsg
 Contains the detailed message of this exception, if any.
std::string _filename
 Contains the filename where this exception was thrown.
std::string _function
 Contains the function name in which this exception was thrown.
std::string _line
 Contains the line number where this exception was thrown.

Static Private Attributes

static std::string ErrorStrings [NUM_ERRORS]
 Error messages corresponding to the exceptions enumerated above.

Detailed Description

Error handling in libDAI is done by throwing an instance of the Exception class.

The Exception class inherits from std::runtime_error. It defines several types of exceptions and corresponding error messages. The recommended way to throw an instance of the Exception class is by using the DAI_THROW or DAI_THROWE macros.

Examples:

example.cpp, and uai2010-aie-solver.cpp.


Member Enumeration Documentation

Enumeration of exceptions used in libDAI.


Constructor & Destructor Documentation

dai::Exception::Exception ( Code  code,
const char *  filename,
const char *  function,
const char *  line,
const std::string &  detailedMsg 
) [inline]

Constructor.

dai::Exception::~Exception ( ) throw () [inline]

Destructor.


Member Function Documentation

Code dai::Exception::getCode ( ) const [inline]

Returns error code of this exception.

Examples:
example.cpp.
Code dai::Exception::code ( ) const [inline]

Returns error code of this exception.

Deprecated:
Please use dai::Exceptions::getCode() instead
const std::string& dai::Exception::getMsg ( ) const [inline]

Returns short error message of this exception.

const std::string& dai::Exception::getDetailedMsg ( ) const [inline]

Returns detailed error message of this exception.

const std::string& dai::Exception::getFilename ( ) const [inline]

Returns filename where this exception was thrown.

const std::string& dai::Exception::getFunction ( ) const [inline]

Returns function name in which this exception was thrown.

const std::string& dai::Exception::getLine ( ) const [inline]

Returns line number where this exception was thrown.

const std::string& dai::Exception::message ( const Code  c) const [inline]

Returns error message corresponding to an error code.


Member Data Documentation

Contains the error code of this exception.

std::string dai::Exception::_detailedMsg [private]

Contains the detailed message of this exception, if any.

std::string dai::Exception::_filename [private]

Contains the filename where this exception was thrown.

std::string dai::Exception::_function [private]

Contains the function name in which this exception was thrown.

std::string dai::Exception::_line [private]

Contains the line number where this exception was thrown.

std::string dai::Exception::ErrorStrings [static, private]
Initial value:
 {
        "Feature not implemented",
        "Assertion failed",
        "Impossible typecast",
        "Requested object not found",
        "Requested belief not available",
        "Unknown ENUM value",
        "Unknown DAI algorithm",
        "Unrecognized parameter estimation method",
        "Unknown Property type",
        "Unknown Property",
        "Malformed Property",
        "Not all mandatory Properties specified",
        "Invalid alias",
        "Cannot read file",
        "Cannot write file",
        "Invalid FactorGraph file",
        "Invalid Evidence file",
        "Invalid Expectation-Maximization file",
        "Quantity not normalizable",
        "Multiple undo levels unsupported",
        "FactorGraph is not connected",
        "Internal error",
        "Runtime error",
        "Out of memory"
    }

Error messages corresponding to the exceptions enumerated above.


The documentation for this class was generated from the following files: