OPAL (Object Oriented Parallel Accelerator Library)
2024.2
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>
39
void
translateException
(T
const
& exception) {
40
PyErr_SetString(PyExc_RuntimeError, exception.what());
41
}
42
44
template
<
class
T>
45
void
translateOpalException
(T
const
& exception) {
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
PyOpal
Definition
ExceptionTranslation.cpp:21
PyOpal::ExceptionTranslation
Definition
ExceptionTranslation.cpp:22
PyOpal::ExceptionTranslation::translateOpalException
void translateOpalException(T const &exception)
Definition
ExceptionTranslation.h:45
PyOpal::ExceptionTranslation::registerExceptions
void registerExceptions()
Definition
ExceptionTranslation.cpp:23
PyOpal::ExceptionTranslation::translateException
void translateException(T const &exception)
Definition
ExceptionTranslation.h:39