Skip to content

Commit cdbb57d

Browse files
committedAug 22, 2017
Don't throw python exception when modeler algorithm is missing inputs
Instead use nicer messagebar for feedback. Also fix untranslatable strings. Refs #17028
1 parent 367aba7 commit cdbb57d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎python/plugins/processing/modeler/ModelerParametersDialog.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,13 @@ def createAlgorithm(self):
303303
for param in self._alg.parameterDefinitions():
304304
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
305305
continue
306-
val = self.wrappers[param.name()].value()
306+
try:
307+
val = self.wrappers[param.name()].value()
308+
except InvalidParameterValue:
309+
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
310+
level=QgsMessageBar.WARNING)
311+
return None
312+
307313
if isinstance(val, QgsProcessingModelChildParameterSource):
308314
val = [val]
309315
elif not (isinstance(val, list) and all([isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
@@ -313,7 +319,7 @@ def createAlgorithm(self):
313319
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
314320
not param.checkValueIsAcceptable(subval.staticValue())) \
315321
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
316-
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description(),
322+
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
317323
level=QgsMessageBar.WARNING)
318324
return None
319325
alg.addParameterSources(param.name(), val)

0 commit comments

Comments
 (0)
Please sign in to comment.