FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
Exception::FMTexceptionhandler Class Reference

#include <FMTexceptionhandler.hpp>

Inheritance diagram for Exception::FMTexceptionhandler:
[legend]
Collaboration diagram for Exception::FMTexceptionhandler:
[legend]

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 FMTexceptionhandlergetCPLdata ()
 
virtual void handelCPLerror (int eErrClass, int nError, const char *pszErrorMsg)
 
FMTexceptionhandleroperator= (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::FMTexcerrorstowarnings
 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FMTexceptionhandler() [1/3]

Exception::FMTexceptionhandler::FMTexceptionhandler ( )

Default constructor for FMTexceptionhandler.

◆ ~FMTexceptionhandler()

virtual Exception::FMTexceptionhandler::~FMTexceptionhandler ( )
virtualdefault

Default virtual destructor for FMTexceptionhandler.

◆ FMTexceptionhandler() [2/3]

Exception::FMTexceptionhandler::FMTexceptionhandler ( const FMTexceptionhandler rhs)

Copy constructor for FMTexceptionhandler.

◆ FMTexceptionhandler() [3/3]

Exception::FMTexceptionhandler::FMTexceptionhandler ( const std::shared_ptr< Logging::FMTlogger > &  logger)

Constructor with logger.

Member Function Documentation

◆ checksignals()

void Exception::FMTexceptionhandler::checksignals ( ) const

Check signals in R and Python, if we are on the main thread.

◆ disablenestedexceptions()

void Exception::FMTexceptionhandler::disablenestedexceptions ( )

Disable the nested exception throw.

◆ enablenestedexceptions()

void Exception::FMTexceptionhandler::enablenestedexceptions ( )

Enable the nested exception throw.

◆ getCPLdata()

virtual FMTexceptionhandler * Exception::FMTexceptionhandler::getCPLdata ( )
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.

◆ gutsofexceptionlog()

void Exception::FMTexceptionhandler::gutsofexceptionlog ( const std::exception &  texception,
const int &  level 
)
protected

The guts of logging exceptions...

◆ gutsofprintexceptions()

void Exception::FMTexceptionhandler::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 
)
protected

The guts of printexceptions.

◆ handelCPLerror()

virtual void Exception::FMTexceptionhandler::handelCPLerror ( int  eErrClass,
int  nError,
const char *  pszErrorMsg 
)
virtual

◆ ismainthread()

bool Exception::FMTexceptionhandler::ismainthread ( ) const
protected

Return true if we are on the main thread.

◆ isthisthreadthrowed()

bool Exception::FMTexceptionhandler::isthisthreadthrowed ( ) const
protected

Return true if this thread throwed

◆ isthreadregistered()

bool Exception::FMTexceptionhandler::isthreadregistered ( ) const
protected

Return true if the thread is registered.

◆ isthrowedonthread()

bool Exception::FMTexceptionhandler::isthrowedonthread ( ) const
protected

Return true if an exception been thrown on a thread.

◆ needtorethrow()

bool Exception::FMTexceptionhandler::needtorethrow ( ) const
protected

If usenested exceptions and exception == function error then it will be true and the exception will be rethrown.

◆ operator=()

FMTexceptionhandler & Exception::FMTexceptionhandler::operator= ( const FMTexceptionhandler rhs)

Default assignment operator for FMTexceptionhandler.

◆ passinlogger()

void Exception::FMTexceptionhandler::passinlogger ( const std::shared_ptr< Logging::FMTlogger > &  logger)

Pass a logger to the shared pointer of the FMTexceptionhandler class for sharing.

◆ printexceptions()

virtual void Exception::FMTexceptionhandler::printexceptions ( std::string  text,
const std::string &  method,
const int &  line,
const std::string &  fil,
Core::FMTsection  lsection = Core::FMTsection::Empty 
)
virtual

Print all nested exception starting with the first provided by the parameters.

◆ raise()

virtual FMTexception Exception::FMTexceptionhandler::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

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.

◆ raisefromcatch()

virtual FMTexception Exception::FMTexceptionhandler::raisefromcatch ( std::string  text,
const std::string &  method,
const int &  line,
const std::string &  file,
Core::FMTsection  lsection = Core::FMTsection::Empty 
)
virtual

Raise an exception from the catch body it will determine if the exception is unenhdled.

◆ raisefromthreadcatch()

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.

◆ registerworkerthread()

void Exception::FMTexceptionhandler::registerworkerthread ( )
protected

Register a thread so that way the exceptionhandler knows that he is dealing with a slave thread that is not the main one.

◆ reraiseifthreadcrash()

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.

◆ seterrorstowarnings()

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...

◆ setmaxwarningsbeforesilenced()

void Exception::FMTexceptionhandler::setmaxwarningsbeforesilenced ( const size_t &  maxwarningcount)

Settter for maxwarningsbeforesilenced.

◆ throw_nested()

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.

◆ updatestatus()

std::string Exception::FMTexceptionhandler::updatestatus ( const FMTexc  lexception,
const std::string  message 
)
protected

This functions updates the status of the handler adding up to the warning or the error counts. base on the exception type (lexception).

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize function is for serialization, used to do multiprocessing across multiple cpus (pickle in Pyhton)

Member Data Documentation

◆ _errorcount

int Exception::FMTexceptionhandler::_errorcount
protected

Keeps count of the number of error thrown.

◆ _exception

FMTexc Exception::FMTexceptionhandler::_exception
protected

This is the type of the last FMTexception thrown by the FMTexceptionhandler.

◆ _level

FMTlev Exception::FMTexceptionhandler::_level
protected

This is the level of the last FMTexception thrown by the FMTexceptionhandler.

◆ _logger

std::shared_ptr<Logging::FMTlogger> Exception::FMTexceptionhandler::_logger
protected

pointer to the logger used to print the warning / error.

◆ _specificwarningcount

std::unordered_map<int,size_t> Exception::FMTexceptionhandler::_specificwarningcount

Keeps count of the number of each type of warning thrown.

◆ _warningcount

int Exception::FMTexceptionhandler::_warningcount
protected

Keeps count of the number of warning thrown.

◆ crashedthreadid

boost::thread::id Exception::FMTexceptionhandler::crashedthreadid
staticprotected

The thread id of the crashed thread.

◆ errorstowarnings

std::vector<Exception::FMTexc> Exception::FMTexceptionhandler::errorstowarnings
protected

If an error is in this list it's going to processed like a warning.

◆ mainthreadid

boost::thread::id Exception::FMTexceptionhandler::mainthreadid
staticprotected

Main thread id.

◆ maxwarningsbeforesilenced

size_t Exception::FMTexceptionhandler::maxwarningsbeforesilenced
protected

Number of time that the handler throw a certain warning before stop throwing it.

◆ mtx

boost::recursive_mutex Exception::FMTexceptionhandler::mtx
mutableprotected

Mutex for multi-threading.

◆ registered_threads

std::set<boost::thread::id> Exception::FMTexceptionhandler::registered_threads
protected

This is the level of the last FMTexception thrown by the FMTexceptionhandler.

◆ threadcrashexception

std::exception_ptr Exception::FMTexceptionhandler::threadcrashexception
protected

The exception throwed by the faulty thread...

◆ usenestedexceptions

bool Exception::FMTexceptionhandler::usenestedexceptions
protected

If usenested = true then the handler will throw nested exceptions.


The documentation for this class was generated from the following file: