FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
Exception::FMTDefaultExceptionHandler Class Referencefinal

Default exception handler used in FMT, derived from FMTExceptionHandler. More...

#include <FMTDefaultExceptionHandler.h>

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

Public Member Functions

 FMTDefaultExceptionHandler ()
 Default constructor for FMTDefaultExceptionHandler.
 
 FMTDefaultExceptionHandler (const std::unique_ptr< Logging::FMTLogger > &logger)
 Construct a FMTDefaultExceptionHandler with a logger.
 
 ~FMTDefaultExceptionHandler ()=default
 Default destructor for FMTDefaultExceptionHandler.
 
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) override
 Default implementation overriding the base class raise function. See FMTExceptionHandler::raise.
 
FMTExceptionHandlergetCplData () override
 Return an abstract copy of itself, used in handelCplError called back by GDAL. See FMTExceptionHandler::getCplData.
 
void handelCplError (int eErrClass, int nError, const char *pszErrorMsg) override
 Callback used in GDAL. See FMTExceptionHandler::handelCplError.
 
virtual std::unique_ptr< FMTExceptionHandlerclone () const
 clone the FMTdefaulexceptionhandler
 
- Public Member Functions inherited from Exception::FMTExceptionHandler
void checkSignals () const
 Check signals in R and Python if on the main thread.
 
 FMTExceptionHandler ()
 Default constructor for FMTExceptionHandler.
 
virtual ~FMTExceptionHandler ()=default
 Default virtual destructor for FMTExceptionHandler.
 
 FMTExceptionHandler (const FMTExceptionHandler &rhs)
 Copy constructor for FMTExceptionHandler.
 
 FMTExceptionHandler (const std::unique_ptr< Logging::FMTLogger > &logger)
 Construct a FMTExceptionHandler with a logger.
 
void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass a logger to the shared pointer of the handler for sharing.
 
virtual FMTExceptionHandlergetCplData ()
 Return a copy of the abstract handler for use in the FMTCPLErrorHandler function when using GDAL.
 
virtual void handelCplError (int eErrClass, int nError, const char *pszErrorMsg)
 Callback called by GDAL for handling GDAL errors thrown.
 
FMTExceptionHandleroperator= (const FMTExceptionHandler &rhs)
 Default copy assignment operator for FMTExceptionHandler.
 
void throwNested (const std::exception &texception, int &level, bool rethrow=true)
 Throw a nested exception.
 
virtual void printExceptions (std::string text, const std::string &method, const int &line, const std::string &fil, Core::FMTsection lsection=Core::FMTsection::Empty)
 Print all nested exceptions starting with the first provided.
 
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)
 Throw a FMTException based on the exception type, section, message and source location. Also used for warnings.
 
virtual FMTException raiseFromCatch (std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty)
 Raise an exception from a catch body, determining if the exception is unhandled.
 
void 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 a catch body on a worker thread, catching all exceptions and printing them without throwing.
 
void reRaiseIfThreadCrash ()
 Re-raise a multithread error if an exception was raised by any thread.
 
void enableNestedExceptions ()
 Enable the throwing of nested exceptions.
 
void disableNestedExceptions ()
 Disable the throwing of nested exceptions.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Setter for the maximum number of warnings before they are silenced.
 
virtual std::unique_ptr< FMTExceptionHandlerclone () const =0
 clone the FMTExceptionHandler
 

Friends

class boost::serialization::access
 Serialize the FMTDefaultExceptionHandler through its base FMTExceptionHandler for multiprocessing across multiple cpus (pickle in Python).
 

Additional Inherited Members

- Static Public Member Functions inherited from Exception::FMTExceptionHandler
static std::string getErrorDescription (bool p_french, FMTexc p_type)
 get descriptions of the potential errors
 
static std::vector< FMTexcgetErrorsToIgnore ()
 gives you a vector of error you can safely turn into warning using setErrorsToWarning return a vector of FMTexc
 
- Protected Member Functions inherited from Exception::FMTExceptionHandler
void _updateStatus (std::unique_ptr< FMTException > &p_exception)
 Update the status of the handler of the last exception type thrown and modify if it as to be ignored.
 
bool _needToRethrow () const
 Return true if nested exceptions are used and the exception is a function error that must be rethrown.
 
bool _isMainThread () const
 Return true if we are on the main thread.
 
bool _isThrowedOnThread () const
 Return true if an exception has been thrown on a thread.
 
bool _isThisThreadThrowed () const
 Return true if this thread has thrown.
 
void _registerWorkerThread ()
 Register a worker thread so the handler knows it is dealing with a slave thread and not the main one.
 
bool _isThreadRegistered () const
 Return true if the thread is registered.
 
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)
 The guts of printExceptions.
 
void _gutsOfExceptionLog (const std::exception &texception, const int &level)
 The guts of logging exceptions.
 
void _updateWarningCount (const FMTException &p_warning)
 update the warning count and print if max not reached
 
- Static Protected Member Functions inherited from Exception::FMTExceptionHandler
static std::unique_ptr< FMTException_createException (FMTexc p_exception, Core::FMTsection p_section, const std::string &p_message, const std::string &p_method, const std::string &p_file, int p_line)
 Construct a FMTException from an exception type, a section, a message and the location where it occurred.
 
- Protected Attributes inherited from Exception::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.
 
size_t m_maxwarningsbeforesilenced
 Number of time that the handler throw a certain warning before stop throwing it.
 
Logging::FMTLogger_logger
 pointer to the logger used to print the warning / error.
 
bool m_usenestedexceptions
 If usenested = true then the handler will throw nested exceptions.
 
boost::recursive_mutex m_mtx
 Mutex for multi-threading.
 
std::vector< Exception::FMTexcm_errorstowarnings
 If an error is in this list it's going to processed like a warning.
 
std::set< boost::thread::id > m_registered_threads
 This is the level of the last FMTException thrown by the FMTExceptionHandler.
 
std::exception_ptr m_threadcrashexception
 The exception throwed by the faulty thread...
 
- Static Protected Attributes inherited from Exception::FMTExceptionHandler
static boost::thread::id m_mainthreadid
 Main thread id.
 
static boost::thread::id m_crashedthreadid
 The thread id of the crashed thread.
 

Detailed Description

Default exception handler used in FMT, derived from FMTExceptionHandler.

Constructor & Destructor Documentation

◆ FMTDefaultExceptionHandler() [1/2]

Exception::FMTDefaultExceptionHandler::FMTDefaultExceptionHandler ( )

Default constructor for FMTDefaultExceptionHandler.

◆ FMTDefaultExceptionHandler() [2/2]

Exception::FMTDefaultExceptionHandler::FMTDefaultExceptionHandler ( const std::unique_ptr< Logging::FMTLogger > &  logger)

Construct a FMTDefaultExceptionHandler with a logger.

Parameters
[in]loggerthe logger to use.

◆ ~FMTDefaultExceptionHandler()

Exception::FMTDefaultExceptionHandler::~FMTDefaultExceptionHandler ( )
default

Default destructor for FMTDefaultExceptionHandler.

Member Function Documentation

◆ clone()

virtual std::unique_ptr< FMTExceptionHandler > Exception::FMTDefaultExceptionHandler::clone ( ) const
virtual

clone the FMTdefaulexceptionhandler

Returns
a valid cloned FMTdefaulexceptionhandler

Implements Exception::FMTExceptionHandler.

◆ getCplData()

FMTExceptionHandler * Exception::FMTDefaultExceptionHandler::getCplData ( )
overridevirtual

Return an abstract copy of itself, used in handelCplError called back by GDAL. See FMTExceptionHandler::getCplData.

Returns
a pointer to the exception handler.

Reimplemented from Exception::FMTExceptionHandler.

◆ handelCplError()

void Exception::FMTDefaultExceptionHandler::handelCplError ( int  eErrClass,
int  nError,
const char *  pszErrorMsg 
)
overridevirtual

Callback used in GDAL. See FMTExceptionHandler::handelCplError.

Parameters
[in]eErrClassthe error class.
[in]nErrorthe error number.
[in]pszErrorMsgthe error message.

Reimplemented from Exception::FMTExceptionHandler.

◆ raise()

FMTException Exception::FMTDefaultExceptionHandler::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 
)
overridevirtual

Default implementation overriding the base class raise function. See FMTExceptionHandler::raise.

Parameters
[in]lexceptionthe exception type.
[in]textthe message of the exception.
[in]methodthe method where the exception occurred.
[in]linethe line where the exception occurred.
[in]filethe file where the exception occurred.
[in]lsectionthe section in which the exception occurred.
[in]throwitif true throws the exception.
Returns
the raised FMTException.

Reimplemented from Exception::FMTExceptionHandler.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTDefaultExceptionHandler through its base FMTExceptionHandler for multiprocessing across multiple cpus (pickle in Python).

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to serialize to or from.
[in]versionthe serialization version.

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