FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportExceptions.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#ifndef PYEXPORTEXCEPTIONS_H_INCLUDED
9#define PYEXPORTEXCEPTIONS_H_INCLUDED
10
14#include "FMTError.h"
15#include "FMTWarning.h"
16#include "FMTException.h"
17#include "boost/python.hpp"
18
19namespace Python
20{
21
23 {
24 namespace bp = boost::python;
25 bp::object ExceptionModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Exception"))));
26 bp::scope().attr("Exception") = ExceptionModule;
27 bp::scope Exception_scope = ExceptionModule;
28 bp::scope().attr("__doc__") = ".. module:: Exception\n"
29 "\n"
30 " :platform: Unix, Windows\n"
31 " :synopsis: Module used to handel exceptions.\n"
32 "\n";
33
34 //bp::class_<Exception::FMTExceptionHandler>("FMTexceptionhandler", "@DocString(FMTExceptionHandler)");
35
36 bp::class_<Exception::FMTDefaultExceptionHandler/*, bp::bases<Exception::FMTExceptionHandler>*/>("FMTdefaultexceptionhandler", "@DocString(FMTDefaultExceptionHandler)")
38 "@DocString(FMTDefaultExceptionHandler::raise)");
39
40 bp::class_<Exception::FMTQuietExceptionHandler/*, bp::bases<Exception::FMTExceptionHandler >*/>("FMTquietexceptionhandler", "@DocString(FMTQuietExceptionHandler)")
42 "@DocString(FMTQuietExceptionHandler::raise)");
43
44 bp::class_<Exception::FMTDebugExceptionHandler/*, bp::bases<Exception::FMTExceptionHandler >*/>("FMTdebugexceptionhandler", "@DocString(FMTDebugExceptionHandler)")
46 "@DocString(FMTDebugExceptionHandler::raise)");
47
48
49 bp::enum_<Exception::FMTexc>("FMTexc")
50 .value("FMTinvalid_number", Exception::FMTexc::FMTinvalid_number)
51 .value("FMTundefined_attribute", Exception::FMTexc::FMTundefined_attribute)
52 .value("FMTundefined_output", Exception::FMTexc::FMTundefined_output)
53 .value("FMTundefined_action", Exception::FMTexc::FMTundefined_action)
54 .value("FMTinvalid_yield", Exception::FMTexc::FMTinvalid_yield)
55 .value("FMTmissingyield", Exception::FMTexc::FMTmissingyield)
56 .value("FMTundefined_constant", Exception::FMTexc::FMTundefined_constant)
57 .value("FMTinvalid_maskrange", Exception::FMTexc::FMTinvalid_maskrange)
58 .value("FMTunsupported_yield", Exception::FMTexc::FMTunsupported_yield)
59 .value("FMToutput_missing_operator", Exception::FMTexc::FMToutput_missing_operator)
60 .value("FMTinvalidyield_number",Exception::FMTexc::FMTinvalidyield_number)
61 .value("FMTundefinedoutput_attribute", Exception::FMTexc::FMTundefinedoutput_attribute)
62 .value("FMToutput_too_much_operator", Exception::FMTexc::FMToutput_too_much_operator)
63 .value("FMTinvalid_geometry", Exception::FMTexc::FMTinvalid_geometry)
64 .value("FMToveridedyield", Exception::FMTexc::FMToveridedyield)
65 .value("FMTdeathwithlock", Exception::FMTexc::FMTdeathwithlock)
66 .value("FMTsourcetotarget_transition", Exception::FMTexc::FMTsourcetotarget_transition)
67 .value("FMTsame_transitiontargets", Exception::FMTexc::FMTsame_transitiontargets)
68 .export_values();
69
70 definePyList<Exception::FMTexc>();
71
72 bp::class_<Exception::FMTException>Exceptionclass("FMTexception", "@DocString(FMTException)");
73 Exceptionclass.def("gettype", &Exception::FMTException::getType,
74 "@DocString(FMTException::gettype)");
75 Exceptionclass.def("getsection", &Exception::FMTException::getSection,
76 "@DocString(FMTException::getsection)");
77 Exceptionclass.def("what", &Exception::FMTException::what,
78 "@DocString(FMTException::what)");
79
80 bp::class_<Exception::FMTError, bp::bases<Exception::FMTException>>Errorclass("FMTerror", "@DocString(FMTError)");
81 bp::class_<Exception::FMTWarning, bp::bases<Exception::FMTException>>("FMTwarning", "@DocString(FMTWarning)");
82
83 bp::register_exception_translator<Exception::FMTWarning>(&FMTtranslate_warning);
84 FMTexceptiontype = Errorclass.ptr();
85 bp::register_exception_translator<Exception::FMTError>(&FMTtranslate_error);
86
87 }
88
89 }
90
91#endif // PYEXPORTEXCEPTIONS_H_INCLUDED
Exception handler derived from FMTExceptionHandler that reports the source line and file where the ex...
Definition: FMTDebugExceptionHandler.h:21
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
Override the base class raise function with a debug style. See FMTExceptionHandler::raise.
Default exception handler used in FMT, derived from FMTExceptionHandler.
Definition: FMTDefaultExceptionHandler.h:22
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.
Core::FMTsection getSection() const
Return the section in which the exception occurred.
FMTexc getType() const
Return the type of exception held by this FMTException.
const char * what() const noexcept override
Override the what function of the base exception class returning the message string.
Silent exception handler derived from FMTExceptionHandler that throws errors but logs nothing and rai...
Definition: FMTQuietExceptionHandler.h:22
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
Override the base class raise function. See FMTExceptionHandler::raise.
@ FMTundefined_action
Definition: FMTException.h:77
@ FMTsame_transitiontargets
Definition: FMTException.h:124
@ FMTinvalid_yield
Definition: FMTException.h:53
@ FMTdeathwithlock
Definition: FMTException.h:120
@ FMTinvalid_maskrange
Definition: FMTException.h:52
@ FMTsourcetotarget_transition
Definition: FMTException.h:123
@ FMToutput_missing_operator
Definition: FMTException.h:108
@ FMTunsupported_yield
Definition: FMTException.h:68
@ FMToutput_too_much_operator
Definition: FMTException.h:109
@ FMTmissingyield
Definition: FMTException.h:87
@ FMTundefined_attribute
Definition: FMTException.h:64
@ FMTinvalid_number
Definition: FMTException.h:57
@ FMTundefined_output
Definition: FMTException.h:79
@ FMTinvalid_geometry
Definition: FMTException.h:112
@ FMTundefinedoutput_attribute
Definition: FMTException.h:113
@ FMTundefined_constant
Definition: FMTException.h:89
@ FMTinvalidyield_number
Definition: FMTException.h:110
@ FMToveridedyield
Definition: FMTException.h:118
Definition: PYdefinitions.h:14
void exportException()
Definition: PYexportExceptions.h:22