![]() |
libexcept 1.1.19
Stack trace along C++ exceptions
|
#include <exception.h>
Public Member Functions | |
exception_base_t (int const stack_trace_depth=STACK_TRACE_DEPTH) | |
Initialize this Snap! exception. | |
virtual | ~exception_base_t () |
Destructor of the exception base 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. | |
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 64 of file exception.h.
|
explicit |
Initialize the base exception class by generating the output of a stack trace to a list of strings.
[in] | stack_trace_depth | The number of lines to grab in our stack trace. |
Definition at line 294 of file exception.cpp.
References libexcept::COLLECT_STACK_COMPLETE, libexcept::COLLECT_STACK_NO, libexcept::collect_stack_trace(), libexcept::collect_stack_trace_with_line_numbers(), libexcept::COLLECT_STACK_YES, f_stack_trace, and libexcept::get_collect_stack().
|
inlinevirtual |
This destructor is defined to ease derivation when some of the classes have virtual functions.
Definition at line 69 of file exception.h.
std::string libexcept::exception_base_t::get_parameter | ( | std::string const & | name | ) | const |
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 f_parameters.
parameter_t const & libexcept::exception_base_t::get_parameters | ( | ) | const |
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 f_parameters.
|
inline |
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 f_stack_trace.
exception_base_t & libexcept::exception_base_t::set_parameter | ( | std::string const & | name, |
std::string const & | value | ||
) |
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 f_parameters.
|
private |
Definition at line 78 of file exception.h.
Referenced by get_parameter(), get_parameters(), and set_parameter().
|
private |
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 exception_base_t(), and get_stack_trace().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.