FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTException.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8
9
10#ifndef FMTEXCEPTION_Hm_included
11#define FMTEXCEPTION_Hm_included
12
13#include <exception>
14#include <string>
15#include <iostream>
16#include <memory>
17#include "FMTutility.h"
18#include <boost/serialization/access.hpp>
19#include <boost/serialization/base_object.hpp>
20#include <boost/serialization/string.hpp>
21
22
23
25namespace Exception
26{
27// DocString: FMTlev
32 {
37 FMT_range=4
38 };
39
40// DocString: FMTexc
45{
46 None = 0,
134
135// DocString: FMTException
139class FMTEXPORT FMTException : public std::exception
140 {
141 public:
142 // DocString: FMTException()
147 // DocString: ~FMTException()
151 virtual ~FMTException() = default;
152 // DocString: FMTException(FMTexc,FMTlev,Core::FMTsection,const std::string&,const std::string&,const std::string&,const std::string&,const std::string&,const std::string&)
165 FMTException(FMTexc p_exception, FMTlev p_level,Core::FMTsection p_section,const std::string& p_message,
166 const std::string& p_method, const std::string& p_file, const int& p_line,
167 const std::string& p_FrenchDescription, const std::string& p_EnglishDescription);
168 // DocString: FMTException(const FMTException&)
173 FMTException(const FMTException& rhs)=default;
174 // DocString: FMTException::operator=
180 FMTException& operator = (const FMTException& rhs)=default;
181 // DocString: FMTException::getType
187 // DocString: FMTException::getSection
193 // DocString: FMTException::what
198 const char* what() const noexcept override;
199 // DocString: FMTException::hold
204 bool hold() const;
205 // DocString: FMTException::setHold
210 void setHold(bool side);
211 // DocString: FMTException::getMethod
216 inline std::string getMethod() const
217 {
218 return m_method;
219 }
220 // DocString: FMTException::getFile
225 inline std::string getFile() const
226 {
227 return m_file;
228 }
229 // DocString: FMTException::getLine
234 inline int getLine() const
235 {
236 return m_line;
237 }
238 // DocString: FMTException::getDescription(bool)
244 const std::string& getDescription(bool p_french=false) const;
245 // DocString: FMTException::getSrcInfo
250 std::string getSrcInfo() const;
251 // DocString: FMTException::getMessage
256 const std::string& getMessage() const;
257 // DocString: FMTException::getLevel
263 // DocString: FMTException::isFatal
268 bool isFatal() const;
269 // DocString: FMTException::setIgnore
273 void setIgnore();
274 // DocString: FMTException::setPrintLevel
279 void setPrintLevel(int p_level);
280 private:
281 // DocString: FMTException::_getPrintLevel
286 int _getPrintLevel() const;
287 // DocString: FMTException::_getUserMessage
292 const std::string& _getUserMessage() const;
293 // DocString: FMTException::_buildMessage
297 void _buildMessage();
298 // DocString: FMTException::serialize
305 friend class boost::serialization::access;
306 template<class Archive>
307 void serialize(Archive& ar, const unsigned int version);
308 // DocString: FMTException::m_holdup
311 bool m_holdup;
312 // DocString: FMTException::_msg
314 std::string m_msg;
315 // DocString: FMTException::m_exceptiontype
317 FMTexc m_exceptiontype;
318 // DocString: FMTException::m_section
320 Core::FMTsection m_section;
321 // DocString: FMTException::m_method
323 std::string m_method;
324 // DocString: FMTException::m_file
326 std::string m_file;
327 // DocString: FMTException::m_line
329 int m_line;
330 // DocString: FMTException::m_FrenchDescription
332 std::string m_FrenchDescription;
333 // DocString: FMTException::m_EnglishDescription
335 std::string m_EnglishDescription;
336 // DocString: FMTException::m_level
338 FMTlev m_level;
339 // DocString: FMTException::m_PrintLevel
341 int m_PrintLevel;
342 // DocString: FMTException::m_UserMessage
344 std::string m_UserMessage;
345 };
346
347}
348
349
350#endif // FMTEXCEPTION_Hm_included
#define FMTEXPORT
Definition: FMTutility.h:125
Base exception class for FMT holding the type, section and message of a given exception.
Definition: FMTException.h:140
int getLine() const
Return the source file line in which the exception occurred.
Definition: FMTException.h:234
const std::string & getDescription(bool p_french=false) const
Return the description of the exception thrown.
virtual ~FMTException()=default
Default virtual destructor for FMTException.
const std::string & getMessage() const
Return the message of the exception.
std::string getFile() const
Return the source file in which the exception occurred.
Definition: FMTException.h:225
void setPrintLevel(int p_level)
set the level of print and change the message
Core::FMTsection getSection() const
Return the section in which the exception occurred.
FMTlev getLevel() const
Return the level of the exception.
void setIgnore()
set a ignore message to the exception and turn the level to warning
FMTException(FMTexc p_exception, FMTlev p_level, Core::FMTsection p_section, const std::string &p_message, const std::string &p_method, const std::string &p_file, const int &p_line, const std::string &p_FrenchDescription, const std::string &p_EnglishDescription)
Construct a FMTException from an exception type, a section, a message and the location where it occur...
FMTexc getType() const
Return the type of exception held by this FMTException.
bool isFatal() const
return true if it is fatal
FMTException()
Default constructor for FMTException.
const char * what() const noexcept override
Override the what function of the base exception class returning the message string.
std::string getSrcInfo() const
Return a formatted string for the location of the exception.
FMTException(const FMTException &rhs)=default
Default copy constructor for FMTException.
FMTsection
Enumerator describing the sections of a Woodstock model.
Definition: FMTutility.h:32
Namespace for exceptions and exceptions handling (warnings and errors) thrown by FMT and all exceptio...
Definition: FMTAggregateRedefinition.h:11
FMTexc
Enumerator describing the exceptions thrown by FMT.
Definition: FMTException.h:45
@ FMTunhandlederror
Definition: FMTException.h:101
@ FMTinvalidlayer
Definition: FMTException.h:72
@ FMTinvalidoverview
Definition: FMTException.h:74
@ FMTcomma_replacement
Definition: FMTException.h:48
@ FMTinvalidband
Definition: FMTException.h:70
@ FMTunsupported_output
Definition: FMTException.h:80
@ FMTundefined_action
Definition: FMTException.h:77
@ FMTempty_schedules
Definition: FMTException.h:114
@ FMTinvalid_constraint
Definition: FMTException.h:93
@ FMTsame_transitiontargets
Definition: FMTException.h:124
@ FMTemptybound
Definition: FMTException.h:94
@ FMTaggregate_redefinition
Definition: FMTException.h:60
@ FMTunboundedperiod
Definition: FMTException.h:95
@ FMTfunctionfailed
Definition: FMTException.h:98
@ FMTWIN32_Error
Definition: FMTException.h:129
@ FMTnotlinegraph
Definition: FMTException.h:102
@ FMTinvalid_yield
Definition: FMTException.h:53
@ FMTboostgrapherror
Definition: FMTException.h:100
@ FMTyieldmodelprediction
Definition: FMTException.h:122
@ FMTmissinglicense
Definition: FMTException.h:97
@ FMTinvalid_transition
Definition: FMTException.h:55
@ FMTmissingrasterattribute
Definition: FMTException.h:75
@ FMTdeathwithlock
Definition: FMTException.h:120
@ FMTschemefailed
Definition: FMTException.h:116
@ FMTinvalid_action
Definition: FMTException.h:54
@ FMTinvalid_maskrange
Definition: FMTException.h:52
@ FMTgdal_constructor_error
Definition: FMTException.h:111
@ FMTunreachable_threshold
Definition: FMTException.h:131
@ FMTsourcetotarget_transition
Definition: FMTException.h:123
@ FMTunclosedforloop
Definition: FMTException.h:125
@ FMTempty_transition
Definition: FMTException.h:78
@ FMTthreadcrash
Definition: FMTException.h:126
@ FMTmskerror
Definition: FMTException.h:117
@ None
Definition: FMTException.h:46
@ FMTEmpty_OA
Definition: FMTException.h:128
@ FMTmissing_parameter
Definition: FMTException.h:119
@ FMTnonaddedconstraint
Definition: FMTException.h:96
@ FMToutput_missing_operator
Definition: FMTException.h:108
@ FMTcoinerror
Definition: FMTException.h:99
@ FMTunsupported_yield
Definition: FMTException.h:68
@ FMToutput_too_much_operator
Definition: FMTException.h:109
@ FMTundefined_aggregate_value
Definition: FMTException.h:63
@ FMTundefineddeathtransition
Definition: FMTException.h:85
@ FMTmissingfield
Definition: FMTException.h:73
@ FMTMSKnumerical_problem
Definition: FMTException.h:130
@ FMTmissingyield
Definition: FMTException.h:87
@ FMTundefined_attribute
Definition: FMTException.h:64
@ FMTinvalid_transition_case
Definition: FMTException.h:56
@ FMTempty_theme
Definition: FMTException.h:61
@ FMTinvaliddataset
Definition: FMTException.h:69
@ FMTinfeasibleconstraint
Definition: FMTException.h:106
@ FMToutofrangeyield
Definition: FMTException.h:127
@ FMTinvalid_path
Definition: FMTException.h:58
@ FMTinvalid_aggregate
Definition: FMTException.h:51
@ FMTfutur_types
Definition: FMTException.h:49
@ FMTpreexisting_yield
Definition: FMTException.h:67
@ FMTGDALerror
Definition: FMTException.h:104
@ FMTignore
Definition: FMTException.h:86
@ FMTthematic_output_diff
Definition: FMTException.h:107
@ FMTconstants_replacement
Definition: FMTException.h:47
@ FMTinvalid_number
Definition: FMTException.h:57
@ FMTwrong_partial
Definition: FMTException.h:66
@ FMTempty_aggregate
Definition: FMTException.h:62
@ FMTmaxnumberofexception
Definition: FMTException.h:132
@ FMTmissingdevelopment
Definition: FMTException.h:90
@ FMTinvaliddriver
Definition: FMTException.h:81
@ FMTtheme_redefinition
Definition: FMTException.h:59
@ FMTreplanningwarning
Definition: FMTException.h:121
@ FMTunsupported_objective
Definition: FMTException.h:92
@ FMTattribute_redefinition
Definition: FMTException.h:88
@ FMTmissingobjective
Definition: FMTException.h:91
@ FMTundefined_output
Definition: FMTException.h:79
@ FMTinvalid_geometry
Definition: FMTException.h:112
@ FMTundefinedoutput_attribute
Definition: FMTException.h:113
@ FMTunsupported_transition
Definition: FMTException.h:76
@ FMTempty_action
Definition: FMTException.h:65
@ FMTmissing_scenarios
Definition: FMTException.h:115
@ FMTinvalid_theme
Definition: FMTException.h:50
@ FMTundefined_constant
Definition: FMTException.h:89
@ FMTinvalidyield_number
Definition: FMTException.h:110
@ FMTGDALwarning
Definition: FMTException.h:105
@ FMTrangeerror
Definition: FMTException.h:103
@ FMTleakingtransition
Definition: FMTException.h:83
@ FMTinvalidAandT
Definition: FMTException.h:82
@ FMTundefineddeathaction
Definition: FMTException.h:84
@ FMTinvalidrasterblock
Definition: FMTException.h:71
@ FMToveridedyield
Definition: FMTException.h:118
FMTlev
Enumerator describing the kind of exception thrown by FMT.
Definition: FMTException.h:32
@ FMT_range
Definition: FMTException.h:37
@ FMT_logic
Definition: FMTException.h:36
@ FMT_None
Definition: FMTException.h:33
@ FMT_Debug
Definition: FMTException.h:34
@ FMT_Warning
Definition: FMTException.h:35
STL namespace.