Implementation base exception class for API clients to derive new pimpl'd exception types from.
More...
#include <unity/ExceptionImplBase.h>
|
| ExceptionImplBase (Exception const *owner, std::string const &reason) |
| Instantiates an implementation instance for a unity::Exception. More...
|
|
std::string | reason () const |
| Returns the reason set by the derived class's constructor (empty string if none). More...
|
|
std::string | to_string (std::nested_exception const *nested, int indent_level, std::string const &indent) const |
| Returns a string describing the exception, including any exceptions that were nested or chained. More...
|
|
std::exception_ptr | set_earlier (std::exception_ptr earlier_exception) |
| Adds an exception to the exception history chain. More...
|
|
std::exception_ptr | get_earlier () const noexcept |
| Returns the previous exception. More...
|
|
Implementation base exception class for API clients to derive new pimpl'd exception types from.
- See Also
- unity::Exception
unity::ExceptionImplBase::ExceptionImplBase |
( |
Exception const * |
owner, |
|
|
std::string const & |
reason |
|
) |
| |
|
explicit |
Instantiates an implementation instance for a unity::Exception.
- Parameters
-
owner | This must be set to the this pointer of the exception that owns this implementation. |
reason | Further details about the cause of the exception. |
exception_ptr unity::ExceptionImplBase::get_earlier |
( |
) | |
const |
|
noexcept |
Returns the previous exception.
- Returns
- Returns the next-older remembered exception, or
nullptr
, if none.
string unity::ExceptionImplBase::reason |
( |
) | |
const |
Returns the reason set by the derived class's constructor (empty string if none).
Derived classes should include any other state information, such as the value of data members or other relevant detail in the reason
string they pass to the protected constructor.
exception_ptr unity::ExceptionImplBase::set_earlier |
( |
std::exception_ptr |
earlier_exception) | |
|
Adds an exception to the exception history chain.
- Parameters
-
earlier_exception | The parameter must be a nullptr or a std::exception_ptr to an exception that was remembered earlier. This allows a sequence of exceptions to be remembered without having to throw them and is useful for example, in shutdown scenarios where any one of a sequence of steps can fail, but we want to continue and try all the following steps and only throw after all of them have been tried. In this case, each step that fails can add itself to the sequence of remembered exceptions, and finally throw something like ShutdownException . |
- Returns
- A
std::exception_ptr
to this
.
string unity::ExceptionImplBase::to_string |
( |
std::nested_exception const * |
nested, |
|
|
int |
indent_level, |
|
|
std::string const & |
indent |
|
) |
| const |
Returns a string describing the exception, including any exceptions that were nested or chained.
Nested exceptions are indented according to their nesting level. If the exception contains chained exceptions, these are shown in oldest-to-newest order.
- Parameters
-
nested | This must be set to the this pointer of the exception that owns this implementation. |
indent_level | This controls the indent level. The value 0 indicates the outermost level (no indent). |
indent | This controls the amount of indenting per level. The default indent is four spaces. |
- Returns
- The string describing the exception.
The documentation for this class was generated from the following files: