New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw c++ exception when a Python exception occurs while running a algorithm #4764
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Would be nice though if we could
- de-duplicate getTraceback() - e.g. to have a .h file that would be included both from core.sip and from src/python implementation
- have a test that the exception is being thrown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment much on the technical side here...
Anyway this sounds like a good catch!
Small details comments though.
* \ingroup core | ||
* Custom exception class for processing related exceptions. | ||
*/ | ||
class CORE_EXPORT QgsProcessingException : public QgsException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about moving QgsException, QgsCsException and QgsProcessingException all to the same header?
they are almost the same and that would be coherent with the sip file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -153,6 +153,11 @@ | |||
#define SIP_CONVERT_TO_SUBCLASS_CODE(code) | |||
|
|||
/* | |||
* Virtual error handler (/VirtualErrorHandler/) | |||
*/ | |||
#define SIP_VIRTUALERRORHANDLER(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add this to Doxyfile.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry - I failed here. Just couldn't get the linker happy.
Done |
Nice improvement. |
Unfortunately requires a bunch of code to be duplicated from QgsPythonUtilsImpl::getTraceback() into core.sip, but there's no way to avoid this
And auto catch python exceptions and report failure of model
processing are non-fatal. We report them to users, and treat the feature as having no geometry, but don't stop execution.
da491b5
to
c3e24b7
Compare
This PR adds a number of building blocks required for catching python exceptions which occur in overriden virtual c++ methods and converting them to a c++ exception which is catchable in c++ code.
It then adds a new QgsProcessingException exception which is thrown when a python exception occurs while running a processing algorithm.