24 #ifndef LSST_PEX_EXCEPTIONS_EXCEPTION_H
25 #define LSST_PEX_EXCEPTIONS_EXCEPTION_H
32 #include "boost/current_function.hpp"
36 namespace exceptions {
40 #define LSST_EXCEPT_HERE __FILE__, __LINE__, BOOST_CURRENT_FUNCTION
46 #define LSST_EXCEPT(type, ...) type(LSST_EXCEPT_HERE, __VA_ARGS__)
51 #define LSST_EXCEPT_ADD(e, m) e.addMessage(LSST_EXCEPT_HERE, m)
55 #define LSST_EARGS_TYPED \
56 char const* ex_file, int ex_line, char const* ex_func, \
57 std::string const& ex_message
61 #define LSST_EARGS_UNTYPED ex_file, ex_line, ex_func, ex_message
68 #define LSST_EXCEPTION_TYPE(t, b, c) \
69 class t : public b { \
71 t(LSST_EARGS_TYPED) : b(LSST_EARGS_UNTYPED) { }; \
72 t(std::string const & message) : b(message) { }; \
73 virtual char const* getType(void) const throw() { return #c " *"; }; \
74 virtual lsst::pex::exceptions::Exception* clone(void) const { \
75 return new t(*this); \
89 Tracepoint(
char const* file,
int line,
char const* func,
90 std::string
const & message);
109 Exception(
char const* file,
int line,
char const* func,
110 std::string
const& message);
121 explicit Exception(std::string
const & message);
132 void addMessage(
char const* file,
int line,
char const* func,
133 std::string
const& message);
144 virtual std::ostream&
addToStream(std::ostream& stream)
const;
156 virtual char const*
what(
void)
const throw();
164 virtual char const*
getType(
void)
const throw();
174 std::string _message;
Exception(char const *file, int line, char const *func, std::string const &message)
Standard constructor, intended for C++ use via the LSST_EXCEPT() macro.
void addMessage(char const *file, int line, char const *func, std::string const &message)
Add a tracepoint and a message to an exception before rethrowing it (access via LSST_EXCEPT_ADD).
virtual char const * what(void) const
Return a character string summarizing this exception.
Tracepoint(char const *file, int line, char const *func, std::string const &message)
Standard constructor, intended for C++ use.
virtual std::ostream & addToStream(std::ostream &stream) const
Add a text representation of this exception, including its traceback with messages, to a stream.
Traceback const & getTraceback(void) const
Retrieve the list of tracepoints associated with an exception.
virtual Exception * clone(void) const
Return a copy of the exception as an Exception*.
virtual char const * getType(void) const
Return the fully-specified C++ type of a pointer to the exception.
std::ostream & operator<<(std::ostream &stream, Exception const &e)
Push the text representation of an exception onto a stream.
One point in the Traceback vector held by Exception.
std::vector< Tracepoint > Traceback