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
28namespace PyOpal {
29namespace py = boost::python;
30
32namespace ExceptionTranslation {
33
36
38template <class T>
39void translateException(T const& exception) {
40 PyErr_SetString(PyExc_RuntimeError, exception.what());
41}
42
44template <class T>
45void 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
void translateOpalException(T const &exception)
void translateException(T const &exception)