[QGIS-Developer] How to notify an error from QgsProcessingAlgorithm.processAlgorithm ?

Jean-Charles Quillet jeancharles.quillet at gmail.com
Tue Feb 4 07:03:43 PST 2020


Hi !

I'm trying to implement a processing algorithm in Python.

It's not clear how I am supposed to handle errors during the execution of
the algorithms. The documentation is talking about raising the exception
GeoAlgorithmExecutionException
https://qgis.org/pyqgis/3.8/core/QgsProcessingAlgorithm.html#qgis.core.QgsProcessingAlgorithm.processAlgorithm

unfortunately this exception doesn't exist. I've tried to raise
QgsProcessingException. But from the output window, the exception does not
seem to be well handled. I also tried to return an empty dictionary and
then the output window doesn't seem to notify any problem at all. I've
checked out GDAL and GRASS processing plugins but they seem handle errors
differently in a very specific way. GDAL raise an IOError and GRASS report
error with: feedback.reportError

So what is the right way to handle an error in processAlgorithm ?

It's important for me as I want to be able to create new models with the
algorithms from the graphical modeler. So if something goes wrong in the
middle of a set of algorithms, it definitely need to be reported correctly.

Thanks for your help,

Jean-Charles

PS: I'm using QGIS 3.8.3-Zanzibar on Windows
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200204/04152146/attachment.html>


More information about the QGIS-Developer mailing list