Skip to content
Permalink
Browse files

Don't throw python exception when modeler algorithm is missing inputs

Instead use nicer messagebar for feedback. Also fix untranslatable
strings.

Refs #17028
  • Loading branch information
nyalldawson committed Aug 22, 2017
1 parent 367aba7 commit cdbb57d65f95c67c227fd25cee98f5bd58be677c
Showing with 8 additions and 2 deletions.
  1. +8 −2 python/plugins/processing/modeler/ModelerParametersDialog.py
@@ -303,7 +303,13 @@ def createAlgorithm(self):
for param in self._alg.parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
val = self.wrappers[param.name()].value()
try:
val = self.wrappers[param.name()].value()
except InvalidParameterValue:
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
level=QgsMessageBar.WARNING)
return None

if isinstance(val, QgsProcessingModelChildParameterSource):
val = [val]
elif not (isinstance(val, list) and all([isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
@@ -313,7 +319,7 @@ def createAlgorithm(self):
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
not param.checkValueIsAcceptable(subval.staticValue())) \
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description(),
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
level=QgsMessageBar.WARNING)
return None
alg.addParameterSources(param.name(), val)

0 comments on commit cdbb57d

Please sign in to comment.
You can’t perform that action at this time.