diff Sources/RestCallbacks.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 5b3dd10cecc3
line wrap: on
line diff
--- 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<const char*>(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;
     }
   }