Namespace lsst::pex::exceptions

namespace exceptions

Typedefs

typedef std::vector<Tracepoint> Traceback

Functions

std::ostream &operator<<(std::ostream &stream, Exception const &e)

Push the text representation of an exception onto a stream.

Return

Reference to the output stream after adding the text.

Parameters
  • [in] stream: Reference to an output stream.

  • [in] e: Exception to output.

LSST_EXCEPTION_TYPE(LogicError, Exception, lsst::pex::exceptions::LogicError)

Reports errors in the logical structure of the program.

LogicError and its subclasses should be thrown to represent problems, such as violation of logical preconditions or class invariants, that are in principle preventable using defensive programming or other good practices. In many cases, it may not be appropriate to catch them.

This exception should be reserved for mathematical operations that are defined on a limited range of inputs. InvalidParameterError is more appropriate for non-mathematical operations.

See

RuntimeError

See

std::logic_error Reports arguments outside the domain of an operation.

See

std::domain_error

lsst::pex::exceptions::DomainError LSST_EXCEPTION_TYPE(InvalidParameterError, LogicError, lsst::pex::exceptions::InvalidParameterError)

Reports invalid arguments.

This exception reports errors that arise because an argument value has not been accepted.

For example, some collection classes might not be able to handle more than some number of elements, or bit fields might support a limited number of flags.

See

std::invalid_argument Reports attempts to exceed implementation-defined length limits for some classes.

See

std::length_error

lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::LSST_EXCEPTION_TYPE(OutOfRangeError, LogicError, lsst::pex::exceptions::OutOfRangeError)

Reports attempts to access elements outside a valid range of indices.

RuntimeError and its subclasses represent problems that cannot be easily predicted or prevented. In other words, a RuntimeError is a possible outcome of calling a function or method even in well-written programs, and should be handled at the appropriate level.

See

NotFoundError

See

std::out_of_range

Note

pybind11 wrappers should manually translate this exception to py::index_error when appropriate. Some Python language constructs check for exceptions that are exactly IndexError rather than a sub- or superclass. Reports errors that are due to events beyond the control of the program.

In Python, this exception inherits from builtins.RuntimeError.

See

LogicError

See

std::runtime_error

lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::LSST_EXCEPTION_TYPE(RangeError, RuntimeError, lsst::pex::exceptions::RangeError)

Reports when the result of an operation cannot be represented by the destination type.

Situations covered by this exception include lossy type conversions.

In Python, this exception inherits from

builtins.OverflowError.
See

OverflowError

See

UnderflowError

See

std::range_error Reports when the result of an arithmetic operation is too large for the destination type.

See

std::overflow_error

lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::OverflowError lsst::pex::exceptions::LSST_EXCEPTION_TYPE(UnderflowError, RuntimeError, lsst::pex::exceptions::UnderflowError)

Reports when the result of an arithmetic operation is too small for the destination type.

In Python, this exception inherits from builtins.ArithmeticError.

This exception may represent lookup failures in classes that resemble C++ maps or Python dictionaries, but it may also be used when the relationship between an identifier and a resource is more abstract.

See

std::underflow_error Reports attempts to access elements using an invalid key.

In Python, this exception inherits from builtins.LookupError.

See

OutOfRangeError

Note

pybind11 wrappers should manually translate this exception to py::key_error when appropriate. Some Python language constructs check for exceptions that are exactly KeyError rather than a sub- or superclass.

lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::OverflowError lsst::pex::exceptions::NotFoundError lsst::pex::exceptions::LSST_EXCEPTION_TYPE(IoError, RuntimeError, lsst::pex::exceptions::IoError)

Reports errors in external input/output operations.

In Python, this exception inherits from builtins.IOError.

In Python, this exception inherits from

builtins.TypeError.
See

std::ios_base::failure Reports errors from accepting an object of an unexpected or inappropriate type.

Variables

lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::OverflowError lsst::pex::exceptions::NotFoundError lsst::pex::exceptions::LogicError
lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::OverflowError lsst::pex::exceptions::Exception
lsst::pex::exceptions::DomainError lsst::pex::exceptions::LengthError lsst::pex::exceptions::RuntimeError lsst::pex::exceptions::RuntimeError
class Exception : public exception
#include <Exception.h>

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.

struct Tracepoint
#include <Exception.h>

One point in the Traceback vector held by Exception.

namespace python

Functions

template<typename T, typename E = lsst::pex::exceptions::Exception>
pybind11::class_<T, E> declareException(pybind11::module &mod, const std::string &name, const std::string &base)

Helper function for pybind11, used to define new types of exceptions.

While this function creates the class wrapper, the user is still responsible for adding all constructor and member wrappers to the returned py::class_ object.

Template Parameters
  • T: The C++ exception to wrap.

  • E: The C++ base class of T.

Parameters
  • [in] mod: Module to insert the exception into.

  • [in] name: Name of the exception in the module.

  • [in] base: Python name of base class (from pex::exceptions).