Skip to content

Commit

Permalink
Show full traceback on Python expression function exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kannes authored and nyalldawson committed Feb 18, 2022
1 parent e8a1f95 commit 1877b36
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/core/additions/qgsfunction.py
Expand Up @@ -20,6 +20,7 @@

import inspect
import string
import traceback
from builtins import str
from qgis.PyQt.QtCore import QCoreApplication
from qgis._core import QgsExpressionFunction, QgsExpression, QgsMessageLog, QgsFeatureRequest, Qgis
Expand Down Expand Up @@ -83,7 +84,10 @@ def func(self, values, context, parent, node):
self.function(values, feature, parent, context)
return self.function(values, feature, parent)
except Exception as ex:
parent.setEvalErrorString(str(ex))
tb = traceback.format_exception(None, ex, ex.__traceback__)
formatted_traceback = ''.join(tb)
formatted_exception = f"{ex}:<pre>{formatted_traceback}</pre>"
parent.setEvalErrorString(formatted_exception)
return None

def usesGeometry(self, node):
Expand Down

0 comments on commit 1877b36

Please sign in to comment.