Mercurial > hg > orthanc-python
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:df7b4f8a0437 | 3:26762eb9d704 |
---|---|
93 PythonObject args2(lock, PyTuple_New(2)); | 93 PythonObject args2(lock, PyTuple_New(2)); |
94 PyTuple_SetItem(args2.GetPyObject(), 0, pInst); | 94 PyTuple_SetItem(args2.GetPyObject(), 0, pInst); |
95 PyTuple_SetItem(args2.GetPyObject(), 1, PyUnicode_FromString(uri)); | 95 PyTuple_SetItem(args2.GetPyObject(), 1, PyUnicode_FromString(uri)); |
96 // No need to decrement refcount with "PyTuple_SetItem()" | 96 // No need to decrement refcount with "PyTuple_SetItem()" |
97 | 97 |
98 | |
99 /** | 98 /** |
100 * Construct the named arguments from the "request" argument | 99 * Construct the named arguments from the "request" argument |
101 **/ | 100 **/ |
102 const char* method; | 101 const char* method; |
103 switch (request->method) | 102 switch (request->method) |
170 { | 169 { |
171 PyDict_SetItemString(kw.GetPyObject(), "body", PyBytes_FromStringAndSize( | 170 PyDict_SetItemString(kw.GetPyObject(), "body", PyBytes_FromStringAndSize( |
172 reinterpret_cast<const char*>(request->body), request->bodySize)); | 171 reinterpret_cast<const char*>(request->body), request->bodySize)); |
173 } | 172 } |
174 | 173 |
175 | |
176 /** | 174 /** |
177 * Call the user-defined function | 175 * Call the user-defined function |
178 **/ | 176 **/ |
179 PythonObject result(lock, PyObject_Call( | 177 PythonObject result(lock, PyObject_Call( |
180 (*it)->GetCallback(), args2.GetPyObject(), kw.GetPyObject())); | 178 (*it)->GetCallback(), args2.GetPyObject(), kw.GetPyObject())); |
181 | 179 |
180 std::string traceback; | |
181 if (lock.HasErrorOccurred(traceback)) | |
182 { | |
183 OrthancPlugins::LogError("Error in the REST callback, traceback:\n" + traceback); | |
184 ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); | |
185 } | |
186 | |
182 return; | 187 return; |
183 } | 188 } |
184 } | 189 } |
185 | 190 |
186 // Should never happen | 191 // Should never happen |