![]() |
libexcept 1.1.19
Stack trace along C++ exceptions
|
#include <exception.h>
Public Member Functions | |
exception_t (char const *what, int const stack_trace_depth=STACK_TRACE_DEPTH) | |
Initialize an exception from a C string. | |
exception_t (std::string const &what, int const stack_trace_depth=STACK_TRACE_DEPTH) | |
Initialize an exception from a C++ string. | |
virtual | ~exception_t () override |
Destructor of the exception class. | |
std::string | get_parameter (std::string const &name) const |
Retrieve one of the exception parameters. | |
parameter_t const & | get_parameters () const |
Retrieve the set of exception parameters. | |
stack_trace_t const & | get_stack_trace () const |
Retrieve the stack trace. | |
exception_base_t & | set_parameter (std::string const &name, std::string const &value) |
Set a parameter in this exception. | |
virtual char const * | what () const override throw () |
Retrieve the what parameter as passed to the constructor. | |
Private Attributes | |
parameter_t | f_parameters = parameter_t() |
stack_trace_t | f_stack_trace = stack_trace_t() |
The variable where the exception stack trace gets saved. | |
Definition at line 111 of file exception.h.
|
explicit |
This function initializes an exception settings its 'what' string to the specified what
parameter.
[in] | what | The string used to initialize the exception what parameter. |
[in] | stack_trace_depth | The number of lines to grab in our stack trace. |
Definition at line 569 of file exception.cpp.
|
explicit |
This function initializes an exception settings its 'what' string to the specified what
parameter.
[in] | what | The string used to initialize the exception what parameter. |
[in] | stack_trace_depth | The number of lines to grab in our stack trace. |
Definition at line 595 of file exception.cpp.
|
inlineoverridevirtual |
This destructor is defined to ease derivation when some of the classes have virtual functions.
Definition at line 119 of file exception.h.
|
inherited |
Exceptions can be assigned parameters with the set_parameter() function. For example, you could include a filename as a parameter. This is useful when sending logs to a database. It can simplify your searches to know exact parameters instead of trying to parse strings.
[in] | name | The name of the parameter to search for. |
Definition at line 346 of file exception.cpp.
References libexcept::exception_base_t::f_parameters.
|
inherited |
This function returns a reference to all the parameters found in this exception. In most cases, exceptions do not have parameters, however, we intend to change that as we continue work on our libraries.
Definition at line 329 of file exception.cpp.
References libexcept::exception_base_t::f_parameters.
|
inlineinherited |
This function retreives a reference to the vector of strings representing the stack trace at the time the exception was raised.
Definition at line 75 of file exception.h.
References libexcept::exception_base_t::f_stack_trace.
|
inherited |
You may add parameters to your exceptions simply by calling this function.
Parameters are given a name. At the moment the name is not restricted, however, if you want to make sure that it works in most places (i.e. in the snaplogger), then you probably want to limit the name to this regex:
Parameter values are strings.
This is an exception, so we do not raise an exception if the name of a parameter is considered invalid. At the moment, an empty string is considered invalid.
[in] | name | The name of the parameter. It cannot be empty. |
[in] | value | The value of this parameter. |
Definition at line 381 of file exception.cpp.
References libexcept::exception_base_t::f_parameters.
|
overridevirtual |
This function returns the what
description of the exception when the exception was initialized.
Definition at line 615 of file exception.cpp.
|
privateinherited |
Definition at line 78 of file exception.h.
Referenced by libexcept::exception_base_t::get_parameter(), libexcept::exception_base_t::get_parameters(), and libexcept::exception_base_t::set_parameter().
|
privateinherited |
This parameter holds the vector of strings representing the stack trace at the time an exception was raised and an instance of the exception_base_t class was created.
Definition at line 79 of file exception.h.
Referenced by libexcept::exception_base_t::exception_base_t(), and libexcept::exception_base_t::get_stack_trace().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.