8#ifndef FMTexceptionhandler_H_INCLUDED
9#define FMTexceptionhandler_H_INCLUDED
13#include <unordered_map>
14#include <boost/serialization/serialization.hpp>
15#include <boost/serialization/nvp.hpp>
16#include <boost/serialization/export.hpp>
20#include <boost/thread.hpp>
37 friend class boost::serialization::access;
38 template<
class Archive>
39 void serialize(Archive& ar,
const unsigned int version)
41 ar & BOOST_SERIALIZATION_NVP(_level);
42 ar & BOOST_SERIALIZATION_NVP(_exception);
43 ar & BOOST_SERIALIZATION_NVP(_errorcount);
44 ar & BOOST_SERIALIZATION_NVP(_warningcount);
45 ar & BOOST_SERIALIZATION_NVP(_logger);
46 ar & BOOST_SERIALIZATION_NVP(usenestedexceptions);
66 std::shared_ptr<Logging::FMTlogger>
_logger;
73 mutable boost::recursive_mutex
mtx;
131 const std::string& method,
const int& line,
const std::string& fil,
179 #if defined FMTWITHGDAL
184 virtual void handelCPLerror(
int eErrClass,
int nError,
const char * pszErrorMsg);
195 void throw_nested(
const std::exception& texception,
int& level,
bool rethrow=
true);
201 const std::string& method,
const int& line,
const std::string& fil,
209 const std::string& method,
const int& line,
const std::string& file,
216 const std::string& method,
const int& line,
const std::string& file,
225 const std::string& method,
const int& line,
const std::string& file,
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTexception.hpp:134
Definition: FMTexceptionhandler.hpp:32
FMTexc _exception
This is the type of the last FMTexception thrown by the FMTexceptionhandler.
Definition: FMTexceptionhandler.hpp:54
void seterrorstowarnings(const std::vector< Exception::FMTexc > &errors)
std::string updatestatus(const FMTexc lexception, const std::string message)
void setmaxwarningsbeforesilenced(const size_t &maxwarningcount)
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)
size_t maxwarningsbeforesilenced
Number of time that the handler throw a certain warning before stop throwing it.
Definition: FMTexceptionhandler.hpp:63
std::vector< Exception::FMTexc > errorstowarnings
If an error is in this list it's going to processed like a warning.
Definition: FMTexceptionhandler.hpp:76
void checksignals() const
bool isthrowedonthread() 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 enablenestedexceptions()
bool isthisthreadthrowed() const
FMTlev _level
This is the level of the last FMTexception thrown by the FMTexceptionhandler.
Definition: FMTexceptionhandler.hpp:51
void passinlogger(const std::shared_ptr< Logging::FMTlogger > &logger)
int _warningcount
Keeps count of the number of warning thrown.
Definition: FMTexceptionhandler.hpp:60
void gutsofexceptionlog(const std::exception &texception, const int &level)
void reraiseifthreadcrash()
static boost::thread::id mainthreadid
Main thread id.
Definition: FMTexceptionhandler.hpp:82
void disablenestedexceptions()
virtual void handelCPLerror(int eErrClass, int nError, const char *pszErrorMsg)
void registerworkerthread()
std::exception_ptr threadcrashexception
The exception throwed by the faulty thread...
Definition: FMTexceptionhandler.hpp:88
boost::recursive_mutex mtx
Mutex for multi-threading.
Definition: FMTexceptionhandler.hpp:73
virtual FMTexception raisefromcatch(std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty)
void throw_nested(const std::exception &texception, int &level, bool rethrow=true)
FMTexceptionhandler(const FMTexceptionhandler &rhs)
std::set< boost::thread::id > registered_threads
This is the level of the last FMTexception thrown by the FMTexceptionhandler.
Definition: FMTexceptionhandler.hpp:79
FMTexceptionhandler(const std::shared_ptr< Logging::FMTlogger > &logger)
std::shared_ptr< Logging::FMTlogger > _logger
pointer to the logger used to print the warning / error.
Definition: FMTexceptionhandler.hpp:66
int _errorcount
Keeps count of the number of error thrown.
Definition: FMTexceptionhandler.hpp:57
bool needtorethrow() const
virtual ~FMTexceptionhandler()=default
virtual void printexceptions(std::string text, const std::string &method, const int &line, const std::string &fil, Core::FMTsection lsection=Core::FMTsection::Empty)
virtual FMTexceptionhandler * getCPLdata()
static boost::thread::id crashedthreadid
The thread id of the crashed thread.
Definition: FMTexceptionhandler.hpp:85
bool isthreadregistered() const
bool usenestedexceptions
If usenested = true then the handler will throw nested exceptions.
Definition: FMTexceptionhandler.hpp:69
void raisefromthreadcatch(std::string text, const std::string &method, const int &line, const std::string &file, Core::FMTsection lsection=Core::FMTsection::Empty)
bool ismainthread() const
std::unordered_map< int, size_t > _specificwarningcount
Keeps count of the number of each type of warning thrown.
Definition: FMTexceptionhandler.hpp:141
FMTsection
Definition: FMTutility.hpp:23
@ Empty
Definition: FMTutility.hpp:35
Namespace for exceptions and exceptions handling (warnings and errors) thrown by FMT and all exceptio...
Definition: FMTcplhandler.hpp:16
FMTexc
Definition: FMTexception.hpp:42
FMTlev
Definition: FMTexception.hpp:29