LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions
lsst::pex::exceptions Namespace Reference

Namespaces

namespace  python
 
namespace  version
 
namespace  wrappers
 

Classes

class  DomainError
 Reports arguments outside the domain of an operation. More...
 
class  Exception
 Provides consistent interface for LSST exceptions. More...
 
class  InvalidParameterError
 Reports invalid arguments. More...
 
class  IoError
 Reports errors in external input/output operations. More...
 
class  LengthError
 Reports attempts to exceed implementation-defined length limits for some classes. More...
 
class  LogicError
 Reports errors in the logical structure of the program. More...
 
class  NotFoundError
 Reports attempts to access elements using an invalid key. More...
 
class  OutOfRangeError
 Reports attempts to access elements outside a valid range of indices. More...
 
class  OverflowError
 Reports when the result of an arithmetic operation is too large for the destination type. More...
 
class  RangeError
 Reports when the result of an operation cannot be represented by the destination type. More...
 
class  RuntimeError
 Reports errors that are due to events beyond the control of the program. More...
 
struct  Tracepoint
 One point in the Traceback vector held by Exception. More...
 
class  TypeError
 Reports errors from accepting an object of an unexpected or inappropriate type. More...
 
class  UnderflowError
 Reports when the result of an arithmetic operation is too small for the destination type. More...
 

Typedefs

typedef std::vector< TracepointTraceback
 

Functions

std::ostreamoperator<< (std::ostream &stream, Exception const &e)
 Push the text representation of an exception onto a stream. More...
 
 PYBIND11_MODULE (exceptions, mod)
 

Typedef Documentation

◆ Traceback

Definition at line 95 of file Exception.h.

Function Documentation

◆ operator<<()

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

Push the text representation of an exception onto a stream.

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

Definition at line 105 of file Exception.cc.

105{ return e.addToStream(stream); }

◆ PYBIND11_MODULE()

lsst::pex::exceptions::PYBIND11_MODULE ( exceptions  ,
mod   
)

Definition at line 90 of file exceptions.cc.

90 {
91 py::class_<Tracepoint> clsTracepoint(mod, "Tracepoint");
92
93 clsTracepoint.def(py::init<char const *, int, char const *, std::string const &>())
94 .def_readwrite("_file", &Tracepoint::_file)
95 .def_readwrite("_line", &Tracepoint::_line)
96 .def_readwrite("_func", &Tracepoint::_func)
97 .def_readwrite("_message", &Tracepoint::_message);
98
99 py::class_<Exception> clsException(mod, "Exception");
100
101 clsException.def(py::init<std::string const &>())
102 .def("addMessage", &Exception::addMessage)
103 .def("getTraceback", &Exception::getTraceback)
104 .def("addToStream", &Exception::addToStream)
105 .def("what", &Exception::what)
106 .def("getType", &Exception::getType)
107 .def("clone", &Exception::clone)
108 .def("asString",
109 [](Exception &self) -> std::string {
110 std::ostringstream stream;
111 self.addToStream(stream);
112 return stream.str();
113 })
114 .def("__repr__", [](Exception &self) -> std::string {
116 s << "Exception('" << self.what() << "')";
117 return s.str();
118 });
119
120 py::class_<LogicError, Exception> clsLogicError(mod, "LogicError");
121 clsLogicError.def(py::init<std::string const &>());
122
123 py::class_<NotFoundError, Exception> clsNotFoundError(mod, "NotFoundError");
124 clsNotFoundError.def(py::init<std::string const &>());
125
126 py::class_<RuntimeError, Exception> clsRuntimeError(mod, "RuntimeError");
127 clsRuntimeError.def(py::init<std::string const &>());
128
129 py::class_<IoError, RuntimeError> clsIoError(mod, "IoError");
130 clsIoError.def(py::init<std::string const &>());
131
132 py::class_<OverflowError, RuntimeError> clsOverflowError(mod, "OverflowError");
133 clsOverflowError.def(py::init<std::string const &>());
134
135 py::class_<RangeError, RuntimeError> clsRangeError(mod, "RangeError");
136 clsRangeError.def(py::init<std::string const &>());
137
138 py::class_<TypeError, LogicError> clsTypeError(mod, "TypeError");
139 clsTypeError.def(py::init<std::string const &>());
140
141 py::class_<UnderflowError, RuntimeError> clsUnderflowError(mod, "UnderflowError");
142 clsUnderflowError.def(py::init<std::string const &>());
143
144 py::class_<DomainError, LogicError> clsDomainError(mod, "DomainError");
145 clsDomainError.def(py::init<std::string const &>());
146
147 py::class_<InvalidParameterError, LogicError> clsInvalidParameterError(mod, "InvalidParameterError");
148 clsInvalidParameterError.def(py::init<std::string const &>());
149
150 py::class_<LengthError, LogicError> clsLengthError(mod, "LengthError");
151 clsLengthError.def(py::init<std::string const &>());
152
153 py::class_<OutOfRangeError, LogicError> clsOutOfRangeError(mod, "OutOfRangeError");
154 clsOutOfRangeError.def(py::init<std::string const &>());
155
156 py::register_exception_translator([](std::exception_ptr p) {
157 try {
158 if (p) std::rethrow_exception(p);
159 } catch (const Exception &e) {
160 py::object current_exception;
161 current_exception = py::cast(e.clone(), py::return_value_policy::take_ownership);
162 raiseLsstException(current_exception);
163 }
164 });
165}
Provides consistent interface for LSST exceptions.
Definition: Exception.h:107
Traceback const & getTraceback(void) const noexcept
Retrieve the list of tracepoints associated with an exception.
Definition: Exception.cc:79
virtual char const * getType(void) const noexcept
Return the fully-specified C++ type of a pointer to the exception.
Definition: Exception.cc:101
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Definition: Exception.cc:99
virtual Exception * clone(void) const
Return a copy of the exception as an Exception pointer.
Definition: Exception.cc:103
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).
Definition: Exception.cc:49
virtual std::ostream & addToStream(std::ostream &stream) const
Add a text representation of this exception, including its traceback with messages,...
Definition: Exception.cc:81
T rethrow_exception(T... args)
T str(T... args)