Alsvinn  0.5.3
The fast FVM simulator with UQ support
Namespaces | Macros | Functions
handle_pyerror.hpp File Reference
#include <boost/python.hpp>
#include "alsutils/error/Exception.hpp"

Go to the source code of this file.

Namespaces

 alsfvm
 Various utility functions to implement the tecno flux.
 
 alsfvm::python
 

Macros

#define HANDLE_PYTHON_EXCEPTION
 

Functions

std::string alsfvm::python::handle_pyerror ()
 

Macro Definition Documentation

◆ HANDLE_PYTHON_EXCEPTION

#define HANDLE_PYTHON_EXCEPTION
Value:
std::string pythonErrorMessage = "none"; \
if (PyErr_Occurred()) { \
pythonErrorMessage = alsfvm::python::handle_pyerror(); \
} \
boost::python::handle_exception(); \
PyErr_Clear(); \
THROW("Error running python script:\n" << pythonErrorMessage)
std::string handle_pyerror()
Definition: handle_pyerror.hpp:25

Small macro to handle python exceptions, not in a function to allow for nicer stack trace.

From https://stackoverflow.com/a/6576177