FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportExceptions.hpp
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.hpp"
15#include "FMTwarning.hpp"
16#include "boost/python.hpp"
17
18namespace Python
19{
20
22 {
23 namespace bp = boost::python;
24 bp::object ExceptionModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Exception"))));
25 bp::scope().attr("Exception") = ExceptionModule;
26 bp::scope Exception_scope = ExceptionModule;
27 bp::scope().attr("__doc__") = ".. module:: Exception\n"
28 "\n"
29 " :platform: Unix, Windows\n"
30 " :synopsis: Module used to handel exceptions.\n"
31 "\n";
32
33 bp::class_<Exception::FMTexceptionhandler>("FMTexceptionhandler", "@DocString(FMTexceptionhandler)");
34
35 bp::class_<Exception::FMTdefaultexceptionhandler, bp::bases<Exception::FMTexceptionhandler>>("FMTdefaultexceptionhandler", "@DocString(FMTdefaultexceptionhandler)")
37 "@DocString(FMTdefaultexceptionhandler::raise)");
38
39 bp::class_<Exception::FMTquietexceptionhandler, bp::bases<Exception::FMTexceptionhandler>>("FMTquietexceptionhandler", "@DocString(FMTquietexceptionhandler)")
41 "@DocString(FMTquietexceptionhandler::raise)");
42
43 bp::class_<Exception::FMTdebugexceptionhandler, bp::bases<Exception::FMTexceptionhandler>>("FMTdebugexceptionhandler", "@DocString(FMTdebugexceptionhandler)")
45 "@DocString(FMTdebugexceptionhandler::raise)");
46
47
48 bp::enum_<Exception::FMTexc>("FMTexc")
49 .value("FMTinvalid_number", Exception::FMTexc::FMTinvalid_number)
50 .value("FMTundefined_attribute", Exception::FMTexc::FMTundefined_attribute)
51 .value("FMTundefined_output", Exception::FMTexc::FMTundefined_output)
52 .value("FMTundefined_action", Exception::FMTexc::FMTundefined_action)
53 .value("FMTinvalid_yield", Exception::FMTexc::FMTinvalid_yield)
54 .value("FMTmissingyield", Exception::FMTexc::FMTmissingyield)
55 .value("FMTundefined_constant", Exception::FMTexc::FMTundefined_constant)
56 .value("FMTinvalid_maskrange", Exception::FMTexc::FMTinvalid_maskrange)
57 .value("FMTunsupported_yield", Exception::FMTexc::FMTunsupported_yield)
58 .value("FMToutput_missing_operator", Exception::FMTexc::FMToutput_missing_operator)
59 .value("FMTinvalidyield_number",Exception::FMTexc::FMTinvalidyield_number)
60 .value("FMTundefinedoutput_attribute", Exception::FMTexc::FMTundefinedoutput_attribute)
61 .value("FMToutput_too_much_operator", Exception::FMTexc::FMToutput_too_much_operator)
62 .value("FMTinvalid_geometry", Exception::FMTexc::FMTinvalid_geometry)
63 .value("FMToveridedyield", Exception::FMTexc::FMToveridedyield)
64 .value("FMTdeathwithlock", Exception::FMTexc::FMTdeathwithlock)
65 .value("FMTsourcetotarget_transition", Exception::FMTexc::FMTsourcetotarget_transition)
66 .value("FMTsame_transitiontargets", Exception::FMTexc::FMTsame_transitiontargets)
67 .export_values();
68
69 define_pylist<Exception::FMTexc>();
70
71 bp::class_<Exception::FMTexception>Exceptionclass("FMTexception", "@DocString(FMTexception)");
72 Exceptionclass.def("gettype", &Exception::FMTexception::gettype,
73 "@DocString(FMTexception::gettype)");
74 Exceptionclass.def("getsection", &Exception::FMTexception::getsection,
75 "@DocString(FMTexception::getsection)");
76 Exceptionclass.def("what", &Exception::FMTexception::what,
77 "@DocString(FMTexception::what)");
78
79 bp::class_<Exception::FMTerror, bp::bases<Exception::FMTexception>>Errorclass("FMTerror", "@DocString(FMTerror)");
80 bp::class_<Exception::FMTwarning, bp::bases<Exception::FMTexception>>("FMTwarning", "@DocString(FMTwarning)");
81
82 bp::register_exception_translator<Exception::FMTwarning>(&FMTtranslate_warning);
83 FMTexceptiontype = Errorclass.ptr();
84 bp::register_exception_translator<Exception::FMTerror>(&FMTtranslate_error);
85
86 }
87
88 }
89
90#endif // PYEXPORTEXCEPTIONS_H_INCLUDED
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
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
Core::FMTsection getsection() const
const char * what() const override
FMTexc gettype() const
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
@ FMTundefined_action
Definition: FMTexception.hpp:74
@ FMTsame_transitiontargets
Definition: FMTexception.hpp:122
@ FMTinvalid_yield
Definition: FMTexception.hpp:50
@ FMTdeathwithlock
Definition: FMTexception.hpp:118
@ FMTinvalid_maskrange
Definition: FMTexception.hpp:49
@ FMTsourcetotarget_transition
Definition: FMTexception.hpp:121
@ FMToutput_missing_operator
Definition: FMTexception.hpp:105
@ FMTunsupported_yield
Definition: FMTexception.hpp:65
@ FMToutput_too_much_operator
Definition: FMTexception.hpp:106
@ FMTmissingyield
Definition: FMTexception.hpp:84
@ FMTundefined_attribute
Definition: FMTexception.hpp:61
@ FMTinvalid_number
Definition: FMTexception.hpp:54
@ FMTundefined_output
Definition: FMTexception.hpp:76
@ FMTinvalid_geometry
Definition: FMTexception.hpp:109
@ FMTundefinedoutput_attribute
Definition: FMTexception.hpp:110
@ FMTundefined_constant
Definition: FMTexception.hpp:86
@ FMTinvalidyield_number
Definition: FMTexception.hpp:107
@ FMToveridedyield
Definition: FMTexception.hpp:116
Definition: PYdefinitions.hpp:14
void exportException()
Definition: PYexportExceptions.hpp:21