diff Sources/OnStoredInstanceCallback.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 fd58eb5749ed
line wrap: on
line diff
--- 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)
   {