FMT 0.9.8
Forest management tools for forest planning
|
#include <FMTexceptionhandler.hpp>
Public Member Functions | |
void | checksignals () const |
FMTexceptionhandler () | |
virtual | ~FMTexceptionhandler ()=default |
FMTexceptionhandler (const FMTexceptionhandler &rhs) | |
FMTexceptionhandler (const std::shared_ptr< Logging::FMTlogger > &logger) | |
void | passinlogger (const std::shared_ptr< Logging::FMTlogger > &logger) |
virtual FMTexceptionhandler * | getCPLdata () |
virtual void | handelCPLerror (int eErrClass, int nError, const char *pszErrorMsg) |
FMTexceptionhandler & | operator= (const FMTexceptionhandler &rhs) |
void | throw_nested (const std::exception &texception, int &level, bool rethrow=true) |
virtual void | printexceptions (std::string text, const std::string &method, const int &line, const std::string &fil, Core::FMTsection lsection=Core::FMTsection::Empty) |
virtual FMTexception | raise (FMTexc lexception, std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty, bool throwit=true) |
virtual FMTexception | raisefromcatch (std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty) |
void | raisefromthreadcatch (std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty) |
void | reraiseifthreadcrash () |
void | enablenestedexceptions () |
void | disablenestedexceptions () |
void | seterrorstowarnings (const std::vector< Exception::FMTexc > &errors) |
void | setmaxwarningsbeforesilenced (const size_t &maxwarningcount) |
Public Attributes | |
std::unordered_map< int, size_t > | _specificwarningcount |
Keeps count of the number of each type of warning thrown. | |
Protected Member Functions | |
std::string | updatestatus (const FMTexc lexception, const std::string message) |
bool | needtorethrow () const |
bool | ismainthread () const |
bool | isthrowedonthread () const |
bool | isthisthreadthrowed () const |
void | registerworkerthread () |
bool | isthreadregistered () const |
void | gutsofprintexceptions (std::string text, const std::string &method, const int &line, const std::string &fil, int &levelreference, Core::FMTsection lsection=Core::FMTsection::Empty, bool logfirstlevel=true) |
void | gutsofexceptionlog (const std::exception &texception, const int &level) |
Protected Attributes | |
FMTlev | _level |
This is the level of the last FMTexception thrown by the FMTexceptionhandler. | |
FMTexc | _exception |
This is the type of the last FMTexception thrown by the FMTexceptionhandler. | |
int | _errorcount |
Keeps count of the number of error thrown. | |
int | _warningcount |
Keeps count of the number of warning thrown. | |
size_t | maxwarningsbeforesilenced |
Number of time that the handler throw a certain warning before stop throwing it. | |
std::shared_ptr< Logging::FMTlogger > | _logger |
pointer to the logger used to print the warning / error. | |
bool | usenestedexceptions |
If usenested = true then the handler will throw nested exceptions. | |
boost::recursive_mutex | mtx |
Mutex for multi-threading. | |
std::vector< Exception::FMTexc > | errorstowarnings |
If an error is in this list it's going to processed like a warning. | |
std::set< boost::thread::id > | registered_threads |
This is the level of the last FMTexception thrown by the FMTexceptionhandler. | |
std::exception_ptr | threadcrashexception |
The exception throwed by the faulty thread... | |
Static Protected Attributes | |
static boost::thread::id | mainthreadid |
Main thread id. | |
static boost::thread::id | crashedthreadid |
The thread id of the crashed thread. | |
Friends | |
class | boost::serialization::access |
The FMTexceptionhandler is a base class used to handel error thrown in FMT. It keeps count of the number of warning thrown and error thrown it also has a shared pointer to an abstract FMTlogger. This class is used in the FMTobject class.
Exception::FMTexceptionhandler::FMTexceptionhandler | ( | ) |
Default constructor for FMTexceptionhandler.
|
virtualdefault |
Default virtual destructor for FMTexceptionhandler.
Exception::FMTexceptionhandler::FMTexceptionhandler | ( | const FMTexceptionhandler & | rhs | ) |
Copy constructor for FMTexceptionhandler.
Exception::FMTexceptionhandler::FMTexceptionhandler | ( | const std::shared_ptr< Logging::FMTlogger > & | logger | ) |
Constructor with logger.
void Exception::FMTexceptionhandler::checksignals | ( | ) | const |
void Exception::FMTexceptionhandler::disablenestedexceptions | ( | ) |
Disable the nested exception throw.
void Exception::FMTexceptionhandler::enablenestedexceptions | ( | ) |
Enable the nested exception throw.
|
virtual |
When using GDAL you need this function for abstract usage in the FMTCPLErrorHandler function. it returns a copy of the abstract FMTexceptionhandler.
Reimplemented in Exception::FMTdebugexceptionhandler, Exception::FMTdefaultexceptionhandler, Exception::FMTfreeexceptionhandler, and Exception::FMTquietexceptionhandler.
|
protected |
The guts of logging exceptions...
|
protected |
The guts of printexceptions.
|
virtual |
Function called back by gdal for handling GDAL error thrown.
Reimplemented in Exception::FMTdebugexceptionhandler, Exception::FMTdefaultexceptionhandler, Exception::FMTfreeexceptionhandler, and Exception::FMTquietexceptionhandler.
|
protected |
Return true if we are on the main thread.
|
protected |
Return true if this thread throwed
|
protected |
Return true if the thread is registered.
|
protected |
Return true if an exception been thrown on a thread.
|
protected |
If usenested exceptions and exception == function error then it will be true and the exception will be rethrown.
FMTexceptionhandler & Exception::FMTexceptionhandler::operator= | ( | const FMTexceptionhandler & | rhs | ) |
Default assignment operator for FMTexceptionhandler.
void Exception::FMTexceptionhandler::passinlogger | ( | const std::shared_ptr< Logging::FMTlogger > & | logger | ) |
Pass a logger to the shared pointer of the FMTexceptionhandler class for sharing.
|
virtual |
Print all nested exception starting with the first provided by the parameters.
|
virtual |
This function throw an FMTexception based on the exception type,section,text to write, line in the source code and file in the source code. Use also this function for warnings.
Reimplemented in Exception::FMTdebugexceptionhandler, Exception::FMTdefaultexceptionhandler, Exception::FMTfreeexceptionhandler, and Exception::FMTquietexceptionhandler.
|
virtual |
Raise an exception from the catch body it will determine if the exception is unenhdled.
void Exception::FMTexceptionhandler::raisefromthreadcatch | ( | std::string | text, |
const std::string & | method, | ||
const int & | line, | ||
const std::string & | file, | ||
Core::FMTsection | lsection = Core::FMTsection::Empty |
||
) |
Raise an exception from the catch body it will determine if the exception is unenhdled. Also catch all the exception to make sure their's no exceptions alive in the thread if not on the main thread. Then printalltheexceptions and return without throwing.
|
protected |
Register a thread so that way the exceptionhandler knows that he is dealing with a slave thread that is not the main one.
void Exception::FMTexceptionhandler::reraiseifthreadcrash | ( | ) |
If you have used threads make sure to use this to validate that there's no exception raised by any thread... if there's one it will raise a multithread error.
void Exception::FMTexceptionhandler::seterrorstowarnings | ( | const std::vector< Exception::FMTexc > & | errors | ) |
Very hazardous function if you want to live dangerously you can set a vector of error to be cast to warnings...
void Exception::FMTexceptionhandler::setmaxwarningsbeforesilenced | ( | const size_t & | maxwarningcount | ) |
Settter for maxwarningsbeforesilenced.
void Exception::FMTexceptionhandler::throw_nested | ( | const std::exception & | texception, |
int & | level, | ||
bool | rethrow = true |
||
) |
This function is not used by FMT seems to be usefull for nested exception thrown.
|
protected |
This functions updates the status of the handler adding up to the warning or the error counts. base on the exception type (lexception).
|
friend |
Serialize function is for serialization, used to do multiprocessing across multiple cpus (pickle in Pyhton)
|
protected |
Keeps count of the number of error thrown.
|
protected |
This is the type of the last FMTexception thrown by the FMTexceptionhandler.
|
protected |
This is the level of the last FMTexception thrown by the FMTexceptionhandler.
|
protected |
pointer to the logger used to print the warning / error.
std::unordered_map<int,size_t> Exception::FMTexceptionhandler::_specificwarningcount |
Keeps count of the number of each type of warning thrown.
|
protected |
Keeps count of the number of warning thrown.
|
staticprotected |
The thread id of the crashed thread.
|
protected |
If an error is in this list it's going to processed like a warning.
|
staticprotected |
Main thread id.
|
protected |
Number of time that the handler throw a certain warning before stop throwing it.
|
mutableprotected |
Mutex for multi-threading.
|
protected |
This is the level of the last FMTexception thrown by the FMTexceptionhandler.
|
protected |
The exception throwed by the faulty thread...
|
protected |
If usenested = true then the handler will throw nested exceptions.