Skip to content
Permalink
Browse files

Be more verbose on exceptions in geoalgorithms

  • Loading branch information
m-kuhn committed Mar 10, 2016
1 parent 6136658 commit e6785ba513aa0909d3cff21431a5a5cb2c3c265a
@@ -214,8 +214,7 @@ def execute(self, progress=SilentProgress(), model=None):
lines = [self.tr('Uncaught error while executing algorithm')]
lines.append(traceback.format_exc())
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, lines)
raise GeoAlgorithmExecutionException(
unicode(e) + self.tr('\nSee log for more details'))
raise GeoAlgorithmExecutionException(unicode(e) + self.tr('\nSee log for more details'), lines, e)

def _checkParameterValuesBeforeExecuting(self):
for param in self.parameters:
@@ -28,6 +28,18 @@

class GeoAlgorithmExecutionException(Exception):

def __init__(self, msg):
def __init__(self, msg, stack=None, cause=None):
Exception.__init__(self)
self.msg = msg
self.stack = stack
self.cause = cause

def __str__(self):
msg = self.msg.split('\n')
msg = ' | ' + '\n | '.join(msg)

stack = '\n'.join(self.stack)
stack = stack.split('\n')
stack = ' ' + '\n '.join(stack)

return '\n\n Message:\n{}\n\n Stack:\n\n{}'.format(msg, stack)
@@ -38,6 +38,7 @@

import processing

from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.gui import AlgorithmExecutor

from qgis.core import (
@@ -95,8 +96,8 @@ def check_algorithm(self, name, defs):
expectFailure = eval(defs['expectedFailure'][-1])

def doCheck():
print(alg.getAsCommand())
self.assertTrue(AlgorithmExecutor.runalg(alg))
alg.execute()

self.check_results(alg.getOutputValuesAsDictionary(), defs['results'])

if expectFailure:

0 comments on commit e6785ba

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