I'm trying to use QgsProcessingException
within a processing script if the output parameter is empty or corresponds to something.
In the specific case the output defined is QgsProcessingParameterFolderDestination
and I would like to display the nice yellow warning in the main dialog if the path chosen is equal to a specific path and not allowing the algorithm to run.
In the processAlgorithm
method I tried to use something like:
# set the output folder
Results = self.parameterAsString(parameters, self.OUTPUT, context)
if Results.startswith('/tmp'):
raise QgsProcessingException(self.tr('Please choose another path'))
it works nice meaning that the algorithm does not start, but the warning message is written in the Log tab and not in the main dialog tab.
Python API are not so useful (https://qgis.org/pyqgis/3.0/core/Processing/QgsProcessingException.html) while C++ API are a little more verbose (https://qgis.org/api/classQgsProcessingException.html)
BTW: using QGIS master (3.1) on a linux debian machine.
To be clear, left the correct handling of the exception for a missing raster parameter, right what happens with the exception with the code of above: