24#ifndef LSST_PEX_EXCEPTIONS_EXCEPTION_H
25#define LSST_PEX_EXCEPTIONS_EXCEPTION_H
33#include "boost/current_function.hpp"
40#define LSST_EXCEPT_HERE __FILE__, __LINE__, BOOST_CURRENT_FUNCTION
48#define LSST_EXCEPT(type, ...) type(LSST_EXCEPT_HERE, __VA_ARGS__)
54#define LSST_EXCEPT_ADD(e, m) e.addMessage(LSST_EXCEPT_HERE, m)
57#define LSST_EARGS_TYPED char const *ex_file, int ex_line, char const *ex_func, std::string const &ex_message
60#define LSST_EARGS_UNTYPED ex_file, ex_line, ex_func, ex_message
69#define LSST_EXCEPTION_TYPE(t, b, c) \
70 class LSST_EXPORT t : public b { \
72 t(LSST_EARGS_TYPED) : b(LSST_EARGS_UNTYPED){}; \
73 t(std::string const& message) : b(message){}; \
74 virtual char const* getType(void) const noexcept { return #c " *"; }; \
75 virtual lsst::pex::exceptions::Exception* clone(void) const { return new t(*this); }; \
117 Exception(
char const* file,
int line,
char const* func,
166 virtual char const*
what(
void)
const noexcept;
175 virtual char const*
getType(
void)
const noexcept;
Provides consistent interface for LSST exceptions.
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 * getType(void) const noexcept
Return the fully-specified C++ type of a pointer to the exception.
virtual Exception * clone(void) const
Return a copy of the exception as an Exception pointer.
virtual std::ostream & addToStream(std::ostream &stream) const
Add a text representation of this exception, including its traceback with messages,...
Traceback const & getTraceback(void) const noexcept
Retrieve the list of tracepoints associated with an exception.
Exception(char const *file, int line, char const *func, std::string const &message)
Standard constructor, intended for C++ use via the LSST_EXCEPT() macro.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
std::ostream & operator<<(std::ostream &stream, Exception const &e)
Push the text representation of an exception onto a stream.
std::vector< Tracepoint > Traceback
Tracepoint(char const *file, int line, char const *func, std::string const &message)
Standard constructor, intended for C++ use.