# HG changeset patch # User Sebastien Jodogne # Date 1585306590 -3600 # Node ID 26762eb9d70493ae9b6ffb31f04abcc88fe52ec5 # Parent df7b4f8a0437fda76e20a679729c136ab9a1d443 reporting of exceptions diff -r df7b4f8a0437 -r 26762eb9d704 Sources/OnChangeCallback.cpp --- a/Sources/OnChangeCallback.cpp Fri Mar 27 07:59:20 2020 +0100 +++ b/Sources/OnChangeCallback.cpp Fri Mar 27 11:56:30 2020 +0100 @@ -152,6 +152,13 @@ PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(change->GetResourceType())); PyTuple_SetItem(args.GetPyObject(), 2, PyUnicode_FromString(change->GetResourceId().c_str())); PythonObject result(lock, PyObject_CallObject(changesCallback_, args.GetPyObject())); + + std::string traceback; + if (lock.HasErrorOccurred(traceback)) + { + OrthancPlugins::LogError("Error in the Python on-change callback, " + "traceback:\n" + traceback); + } } catch (OrthancPlugins::PluginException& e) { diff -r df7b4f8a0437 -r 26762eb9d704 Sources/OnStoredInstanceCallback.cpp --- a/Sources/OnStoredInstanceCallback.cpp Fri Mar 27 07:59:20 2020 +0100 +++ b/Sources/OnStoredInstanceCallback.cpp Fri Mar 27 11:56:30 2020 +0100 @@ -53,7 +53,18 @@ PyTuple_SetItem(args2.GetPyObject(), 1, PyUnicode_FromString(instanceId)); PythonObject result(lock, PyObject_CallObject(storedInstanceCallback_, args2.GetPyObject())); - return OrthancPluginErrorCode_Success; + + std::string traceback; + if (lock.HasErrorOccurred(traceback)) + { + OrthancPlugins::LogError("Error in the Python on-change callback, " + "traceback:\n" + traceback); + return OrthancPluginErrorCode_Plugin; + } + else + { + return OrthancPluginErrorCode_Success; + } } catch (OrthancPlugins::PluginException& e) { diff -r df7b4f8a0437 -r 26762eb9d704 Sources/RestCallbacks.cpp --- a/Sources/RestCallbacks.cpp Fri Mar 27 07:59:20 2020 +0100 +++ b/Sources/RestCallbacks.cpp Fri Mar 27 11:56:30 2020 +0100 @@ -95,7 +95,6 @@ PyTuple_SetItem(args2.GetPyObject(), 1, PyUnicode_FromString(uri)); // No need to decrement refcount with "PyTuple_SetItem()" - /** * Construct the named arguments from the "request" argument **/ @@ -172,13 +171,19 @@ reinterpret_cast(request->body), request->bodySize)); } - /** * Call the user-defined function **/ PythonObject result(lock, PyObject_Call( (*it)->GetCallback(), args2.GetPyObject(), kw.GetPyObject())); - + + std::string traceback; + if (lock.HasErrorOccurred(traceback)) + { + OrthancPlugins::LogError("Error in the REST callback, traceback:\n" + traceback); + ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); + } + return; } }