Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Be more verbose on exceptions in geoalgorithms
  • Loading branch information
m-kuhn committed Mar 10, 2016
1 parent 6136658 commit e6785ba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 1 addition & 2 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion python/plugins/processing/core/GeoAlgorithmExecutionException.py
Expand Up @@ -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)
5 changes: 3 additions & 2 deletions python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -38,6 +38,7 @@

import processing

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

from qgis.core import (
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e6785ba

Please sign in to comment.