mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Exception handling for Python function calls.
This commit is contained in:
parent
79bf945868
commit
acf4e746c0
@ -94,8 +94,22 @@ void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& f
|
|||||||
|
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (PyErr_Occurred()) {
|
||||||
// re-throw python exception
|
PyObject *ptype, *pvalue, *ptraceback;
|
||||||
|
|
||||||
|
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
|
||||||
|
PyObject *pstr_msg = PyObject_Str(pvalue);
|
||||||
|
PyObject *pstr_tb = PyObject_Str(ptraceback);
|
||||||
|
Py_DECREF(pvalue);
|
||||||
|
PyErr_Clear();
|
||||||
|
|
||||||
|
String msg = PyString_AsString(pstr_msg);
|
||||||
|
Py_DECREF(pstr_msg);
|
||||||
|
|
||||||
|
String tb = PyString_AsString(pstr_tb);
|
||||||
|
Py_DECREF(pstr_tb);
|
||||||
|
|
||||||
|
BOOST_THROW_EXCEPTION(runtime_error("Error in Python script:" + msg + " at " + tb));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value vresult = PythonLanguage::MarshalFromPython(result);
|
Value vresult = PythonLanguage::MarshalFromPython(result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user