Skip to content

Commit 98617c9

Browse files
committed
Report errors when executing algs within dialogs
1 parent 93b7c28 commit 98617c9

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -330,32 +330,17 @@ def executeAlgorithm(alg, parameters, context=None, feedback=None, model=None):
330330
context = dataobjects.createContext()
331331

332332
#self.model = model
333-
try:
334-
#self.setOutputCRS()
335-
#self.resolveOutputs()
336-
#self.evaluateParameterValues()
337-
#self.runPreExecutionScript(feedback)
338-
result, ok = alg.run(parameters, context, feedback)
339-
#self.processAlgorithm(parameters, context, feedback)
340-
feedback.setProgress(100)
341-
return result
342-
#self.convertUnsupportedFormats(context, feedback)
343-
#self.runPostExecutionScript(feedback)
344-
except GeoAlgorithmExecutionException as gaee:
345-
lines = [self.tr('Error while executing algorithm')]
346-
lines = []
347-
lines.append(traceback.format_exc())
348-
feedback.reportError(gaee.msg)
349-
QgsMessageLog.logMessage(gaee.msg, self.tr('Processing'), QgsMessageLog.CRITICAL)
350-
raise GeoAlgorithmExecutionException(gaee.msg, lines, gaee)
351-
#except Exception as e:
352-
# If something goes wrong and is not caught in the
353-
# algorithm, we catch it here and wrap it
354-
#lines = [self.tr('Uncaught error while executing algorithm')]
355-
# lines = []
356-
# lines.append(traceback.format_exc())
357-
#QgsMessageLog.logMessage('\n'.join(lines), self.tr('Processing'), QgsMessageLog.CRITICAL)
358-
#raise GeoAlgorithmExecutionException(str(e) + self.tr('\nSee log for more details'), lines, e)
333+
334+
#self.setOutputCRS()
335+
#self.resolveOutputs()
336+
#self.evaluateParameterValues()
337+
#self.runPreExecutionScript(feedback)
338+
result, ok = alg.run(parameters, context, feedback)
339+
#self.processAlgorithm(parameters, context, feedback)
340+
feedback.setProgress(100)
341+
return result, ok
342+
#self.convertUnsupportedFormats(context, feedback)
343+
#self.runPostExecutionScript(feedback)
359344

360345
def helpUrl(self):
361346
return QgsHelp.helpUrl("processing_algs/{}/{}".format(

python/plugins/processing/gui/AlgorithmDialog.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,14 @@ def accept(self):
244244
if command:
245245
ProcessingLog.addToLog(command)
246246
self.buttonCancel.setEnabled(self.alg.flags() & QgsProcessingAlgorithm.FlagCanCancel)
247-
result = executeAlgorithm(self.alg, parameters, context, feedback)
248-
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
249-
feedback.pushInfo(self.tr('Results:'))
250-
feedback.pushCommandInfo(pformat(result))
247+
result, ok = executeAlgorithm(self.alg, parameters, context, feedback)
248+
if ok:
249+
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
250+
feedback.pushInfo(self.tr('Results:'))
251+
feedback.pushCommandInfo(pformat(result))
252+
else:
253+
feedback.reportError(
254+
self.tr('Execution failed after {0:0.2f} seconds'.format(time.time() - start_time)))
251255
feedback.pushInfo('')
252256

253257
self.buttonCancel.setEnabled(False)

0 commit comments

Comments
 (0)