lsst.pex.exceptions  19.0.0-4-g5a8b323+3
Public Member Functions | List of all members
lsst::pex::exceptions::Exception Class Reference

Provides consistent interface for LSST exceptions. More...

#include <Exception.h>

Inheritance diagram for lsst::pex::exceptions::Exception:
std::exception lsst::pex::exceptions::LogicError lsst::pex::exceptions::NotFoundError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::DomainError lsst::pex::exceptions::InvalidParameterError lsst::pex::exceptions::LengthError lsst::pex::exceptions::OutOfRangeError lsst::pex::exceptions::TypeError lsst::pex::exceptions::IoError lsst::pex::exceptions::OverflowError lsst::pex::exceptions::RangeError lsst::pex::exceptions::UnderflowError

Public Member Functions

 Exception (char const *file, int line, char const *func, std::string const &message)
 Standard constructor, intended for C++ use via the LSST_EXCEPT() macro. More...
 
 Exception (std::string const &message)
 Message-only constructor, intended for use from Python only. More...
 
virtual ~Exception (void) noexcept
 
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). More...
 
Traceback const & getTraceback (void) const noexcept
 Retrieve the list of tracepoints associated with an exception. More...
 
virtual std::ostreamaddToStream (std::ostream &stream) const
 Add a text representation of this exception, including its traceback with messages, to a stream. More...
 
virtual char const * what (void) const noexcept
 Return a character string summarizing this exception. More...
 
virtual char const * getType (void) const noexcept
 Return the fully-specified C++ type of a pointer to the exception. More...
 
virtual Exceptionclone (void) const
 Return a copy of the exception as an Exception pointer. More...
 
what (T... args)
 

Detailed Description

Provides consistent interface for LSST exceptions.

All exceptions defined by the LSST Stack are derived from this class. Code should not throw or catch Exception directly, but should instead be written in terms of the appropriate subclasses (e.g., catch RuntimeError to handle all unknown errors).

In Python, this exception inherits from builtins.Exception.

Definition at line 107 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/2]

lsst::pex::exceptions::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.

Parameters
[in]fileFilename (automatically passed in by macro).
[in]lineLine number (automatically passed in by macro).
[in]funcFunction name (automatically passed in by macro).
[in]messageInformational string attached to exception.

Definition at line 42 of file Exception.cc.

◆ Exception() [2/2]

lsst::pex::exceptions::Exception::Exception ( std::string const &  message)
explicit

Message-only constructor, intended for use from Python only.

While this constructor can be called from C++, it's better to use the LSST_EXCEPT macro there, which stores file/line/function information as well. In Python, however, that information is stored outside the exception, so we don't want to duplicate it, and hence this constructor is invoked instead.

Parameters
[in]messageInformational string attached to exception.

Definition at line 45 of file Exception.cc.

◆ ~Exception()

lsst::pex::exceptions::Exception::~Exception ( void  )
virtualnoexcept

Definition at line 47 of file Exception.cc.

Member Function Documentation

◆ addMessage()

void lsst::pex::exceptions::Exception::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).

Parameters
[in]fileFilename (automatically passed in by macro).
[in]lineLine number (automatically passed in by macro).
[in]funcFunction name (automatically passed in by macro).
[in]messageAdditional message to associate with this rethrow.

Definition at line 49 of file Exception.cc.

◆ addToStream()

std::ostream & lsst::pex::exceptions::Exception::addToStream ( std::ostream stream) const
virtual

Add a text representation of this exception, including its traceback with messages, to a stream.

Parameters
[in]streamReference to an output stream.
Returns
Reference to the output stream after adding the text.

Definition at line 81 of file Exception.cc.

◆ clone()

Exception * lsst::pex::exceptions::Exception::clone ( void  ) const
virtual

Return a copy of the exception as an Exception pointer.

Can be overridden by derived classes that add data or methods.

Returns
Pointer to a copy of the exception.

Definition at line 103 of file Exception.cc.

◆ getTraceback()

Traceback const & lsst::pex::exceptions::Exception::getTraceback ( void  ) const
noexcept

Retrieve the list of tracepoints associated with an exception.

Definition at line 79 of file Exception.cc.

◆ getType()

char const * lsst::pex::exceptions::Exception::getType ( void  ) const
virtualnoexcept

Return the fully-specified C++ type of a pointer to the exception.

This is overridden by derived classes (automatically if the LSST_EXCEPTION_TYPE macro is used). It is used by the Python interface.

Returns
String with the C++ type; does not need to be freed/deleted.

Definition at line 101 of file Exception.cc.

◆ what()

char const * lsst::pex::exceptions::Exception::what ( void  ) const
virtualnoexcept

Return a character string summarizing this exception.

This combines all the messages added to the exception, but not the type or traceback (use the stream operator to get this more detailed information).

Not allowed to throw any exceptions.

Returns
String representation; does not need to be freed/deleted.

Definition at line 99 of file Exception.cc.


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