Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
tsa::exception Class Reference

Class tsa::exception used by most classes of the Trading System API library. The class inherits from std::exception (standard C++ library). Class tsa::exception extends std::exception by including the file and line number of the code that originated the exception in the exception message. More...

Inheritance diagram for tsa::exception:
tsa::series_bounds_error

Public Member Functions

 exception (void)
 Constructor.
 
 exception (const char *message)
 Constructor.
 
 exception (const char *message, const source_location &src_loc)
 Constructor. Use SLOC macro as sourceLocation.
 
 exception (const std::string &message, const source_location &src_loc)
 Constructor. Use SLOC macro as sourceLocation.
 
 exception (const char *origin, const char *message, const source_location &src_loc)
 Constructor. Use SLOC macro as sourceLocation.
 
 exception (const object *raisingClassPtr, const std::string &message, const source_location &sourceLocation)
 Constructor.
 
virtual ~exception () throw ()
 Destructor.
 
void id (identifier_t)
 Sets the exception ID.
 
std::string line (void) const
 
const std::stringmessage (void) const
 
const std::stringorigin (void) const
 
virtual const char * what () const throw ()
 Returns the exception message.
 

Detailed Description

Class tsa::exception used by most classes of the Trading System API library. The class inherits from std::exception (standard C++ library). Class tsa::exception extends std::exception by including the file and line number of the code that originated the exception in the exception message.

Raise an exception as follows:

throw tsa::exception("... error ... ", SLOC);

If the exception is thrown by a class derived from tsa::object, then the object's 'this' pointer can be passed to the exception constructor such as:

throw tsa::exception(class_name(), "... error in object... ", SLOC);

Using the 'this' pointer in such a way allows the exception object to enhance the exception message by adding information about the throwing class.