Skip to content

Commit b00a04c

Browse files
committedFeb 27, 2023
[processing] Don't raise uncaught exceptions when trying to generate
GDAL commands for invalid layers This is a partial fix, which at least removes the uncaught exception. Ideally we'd gracefully fall back to using the layer's source (even if it doesn't exist!) in the generated GDAL commands. But that's far from trivial to do. Fixes #51958
1 parent aa4cdd2 commit b00a04c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed
 

‎python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
QSizePolicy,
3434
QDialogButtonBox)
3535

36-
from qgis.core import (QgsProcessingFeedback,
37-
QgsProcessingParameterDefinition)
36+
from qgis.core import (
37+
QgsProcessingException,
38+
QgsProcessingFeedback,
39+
QgsProcessingParameterDefinition
40+
)
3841
from qgis.gui import (QgsMessageBar,
3942
QgsProjectionSelectionWidget,
4043
QgsProcessingAlgorithmDialogBase,
@@ -140,9 +143,12 @@ def parametersHaveChanged(self):
140143
self.text.setPlainText('')
141144
return
142145

143-
commands = self.algorithm().getConsoleCommands(parameters, context, feedback, executing=False)
144-
commands = [c for c in commands if c not in ['cmd.exe', '/C ']]
145-
self.text.setPlainText(" ".join(commands))
146+
try:
147+
commands = self.algorithm().getConsoleCommands(parameters, context, feedback, executing=False)
148+
commands = [c for c in commands if c not in ['cmd.exe', '/C ']]
149+
self.text.setPlainText(" ".join(commands))
150+
except QgsProcessingException as e:
151+
self.text.setPlainText(str(e))
146152
except AlgorithmDialogBase.InvalidParameterValue as e:
147153
self.text.setPlainText(self.tr("Invalid value for parameter '{0}'").format(e.parameter.description()))
148154
except AlgorithmDialogBase.InvalidOutputExtension as e:

0 commit comments

Comments
 (0)
Please sign in to comment.