Skip to content

Commit

Permalink
[processing] Always log python exceptions to logger
Browse files Browse the repository at this point in the history
Because Python code cannot catch and rethrow c++ exceptions
without losing context, we end up getting unknown exceptions
caught by c++ from python code (phew!).

So if we catch a python exception from processing, throw it
into the log so at least there's the full debugging detail
available on the console.

(Not ideal. Would love to see a PR allowing the full error
message to be passed correctly between c++/python/back again)

(cherry-picked from f4445a0)
  • Loading branch information
nyalldawson committed Apr 6, 2018
1 parent 08d85bb commit 2a6feee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/core/core.sip.in
Expand Up @@ -6,6 +6,7 @@ ${DEFAULTDOCSTRINGSIGNATURE}
%ModuleCode

#include "qgsexception.h"
#include "qgslogger.h"

QString getTraceback()
{
Expand Down Expand Up @@ -107,6 +108,7 @@ done:

%VirtualErrorHandler processing_exception_handler
QString trace = getTraceback();
QgsLogger::critical( trace );
SIP_RELEASE_GIL( sipGILState );
throw QgsProcessingException( trace );
%End

0 comments on commit 2a6feee

Please sign in to comment.