Libthreadar 1.6.0
|
Pure virtual class parent of all libthreadar exceptions. More...
#include <exceptions.hpp>
Inherited by libthreadar::exception_bug, libthreadar::exception_feature, libthreadar::exception_memory, libthreadar::exception_range, libthreadar::exception_system, and libthreadar::exception_thread.
Public Member Functions | |
exception_base (const std::string &x_msg) | |
constructor More... | |
exception_base (const exception_base &ref)=default | |
default copy constructor is fine | |
exception_base (exception_base &&ref) noexcept=default | |
default move constructor is fine | |
exception_base & | operator= (const exception_base &ref)=default |
default assignment operator is fine | |
exception_base & | operator= (exception_base &&ref) noexcept=default |
default move operator is fine | |
virtual | ~exception_base ()=default |
destructor | |
void | push_message (const std::string &x_msg) |
to be used in a catch clause to more detailed information of the problem cause, before rethrowing the exception More... | |
unsigned int | size () const |
for site which need to display the information to the user More... | |
const std::string & | operator[] (unsigned int i) const |
for site which need to display the information to the user More... | |
std::string | get_message (const std::string &sep) const |
concatenated messages and use the given separator between messages More... | |
virtual exception_base * | clone () const =0 |
create a new object of the same type and value of the object which clone() method is invoked More... | |
Protected Member Functions | |
void | reset_first_message (const std::string &msg) |
for libthreader internal use only More... | |
Pure virtual class parent of all libthreadar exceptions.
All exception generated by libthreadar follow this interface to provide detailed information about the site of origin of the exception as well as its cause. If the type of exception (see the different exception_* classes that all inherit from class exception_base) is not sufficient for your need and you want a text message of the root cause, all libthreadar exceptions contain a list of messages provided from the source/root cause of the error and completed by messages added by each try/catch block it occured in. You can access these messages by two ways:
You may ignore other features relative to exceptions for normal use of libthreadar
However you are allowed to add new messages to the stack using push_message() and then rethrow the exception for propagation.
Why not concatenating string at each catch{} clause and propagating the exception? Because depending on human languagues, some might well prefer to present this nested informations another way than separating them with ':' from the less specific to the root cause, thus error message translation can be more easy to provide.
Definition at line 87 of file exceptions.hpp.
|
inline |
|
pure virtual |
create a new object of the same type and value of the object which clone() method is invoked
Implemented in libthreadar::exception_memory, libthreadar::exception_bug, libthreadar::exception_thread, libthreadar::exception_system, libthreadar::exception_range, and libthreadar::exception_feature.
std::string libthreadar::exception_base::get_message | ( | const std::string & | sep | ) | const |
concatenated messages and use the given separator between messages
[in] | sep | is a string to insert between messages of the list (like for example ": ") |
|
inline |
for site which need to display the information to the user
[in] | i | is the index of the element of the list to return, it must be stricly lesser than size() |
Definition at line 122 of file exceptions.hpp.
|
inline |
to be used in a catch clause to more detailed information of the problem cause, before rethrowing the exception
Definition at line 111 of file exceptions.hpp.
|
inlineprotected |
for libthreader internal use only
Definition at line 138 of file exceptions.hpp.
|
inline |
for site which need to display the information to the user
Definition at line 116 of file exceptions.hpp.