comparison Sources/OnChangeCallback.cpp @ 3:26762eb9d704

reporting of exceptions
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Mar 2020 11:56:30 +0100
parents 7ed502b17b8f
children 952e969a2240
comparison
equal deleted inserted replaced
2:df7b4f8a0437 3:26762eb9d704
150 PythonObject args(lock, PyTuple_New(3)); 150 PythonObject args(lock, PyTuple_New(3));
151 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromLong(change->GetChangeType())); 151 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromLong(change->GetChangeType()));
152 PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(change->GetResourceType())); 152 PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(change->GetResourceType()));
153 PyTuple_SetItem(args.GetPyObject(), 2, PyUnicode_FromString(change->GetResourceId().c_str())); 153 PyTuple_SetItem(args.GetPyObject(), 2, PyUnicode_FromString(change->GetResourceId().c_str()));
154 PythonObject result(lock, PyObject_CallObject(changesCallback_, args.GetPyObject())); 154 PythonObject result(lock, PyObject_CallObject(changesCallback_, args.GetPyObject()));
155
156 std::string traceback;
157 if (lock.HasErrorOccurred(traceback))
158 {
159 OrthancPlugins::LogError("Error in the Python on-change callback, "
160 "traceback:\n" + traceback);
161 }
155 } 162 }
156 catch (OrthancPlugins::PluginException& e) 163 catch (OrthancPlugins::PluginException& e)
157 { 164 {
158 OrthancPlugins::LogError("Error during Python on-change callback: " + 165 OrthancPlugins::LogError("Error during Python on-change callback: " +
159 std::string(e.What(OrthancPlugins::GetGlobalContext()))); 166 std::string(e.What(OrthancPlugins::GetGlobalContext())));