OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
ExceptionTranslation.h
Go to the documentation of this file.
1 //
2 // Python API for PolynomialCoefficient (part of the multidimensional polynomial fitting routines)
3 //
4 // Copyright (c) 2008-2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
5 //
6 // This file is part of OPAL.
7 //
8 // OPAL is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
15 //
16 
17 #ifndef PYOPAL_PYCORE_EXCEPTIONTRANSLATION_H
18 #define PYOPAL_PYCORE_EXCEPTIONTRANSLATION_H 1
19 
20 #include <Python.h>
21 #include <structmember.h>
22 
23 #include <string>
24 #include <exception>
25 
26 #include <boost/python.hpp>
27 
28 namespace PyOpal {
29 namespace py = boost::python;
30 
32 namespace ExceptionTranslation {
33 
35 void registerExceptions();
36 
38 template <class T>
40  PyErr_SetString(PyExc_RuntimeError, exception.what());
41 }
42 
44 template <class T>
46  std::string msg = exception.what()+" in C++ method "+exception.where();
47  PyErr_SetString(PyExc_RuntimeError, msg.c_str());
48 }
49 
50 
51 }
52 }
53 
54 #endif
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special exception
Definition: LICENSE:157
void translateOpalException(T const &exception)
void translateException(T const &exception)