Commit 588190f6 by Őry Máté

common: store HumanReadableException in activities

parent f9768161
...@@ -47,17 +47,24 @@ class WorkerNotFound(Exception): ...@@ -47,17 +47,24 @@ class WorkerNotFound(Exception):
def activitycontextimpl(act, on_abort=None, on_commit=None): def activitycontextimpl(act, on_abort=None, on_commit=None):
try: try:
try:
yield act yield act
except HumanReadableException as e:
result = e
raise
except BaseException as e: except BaseException as e:
# BaseException is the common parent of Exception and # BaseException is the common parent of Exception and
# system-exiting exceptions, e.g. KeyboardInterrupt # system-exiting exceptions, e.g. KeyboardInterrupt
handler = None if on_abort is None else lambda a: on_abort(a, e) result = create_readable(
result = create_readable(ugettext_noop("Failure."), ugettext_noop("Failure."),
ugettext_noop("Unhandled exception: " ugettext_noop("Unhandled exception: %(error)s"),
"%(error)s"),
error=unicode(e)) error=unicode(e))
raise
except:
logger.exception("Failed activity %s" % unicode(act))
handler = None if on_abort is None else lambda a: on_abort(a, e)
act.finish(succeeded=False, result=result, event_handler=handler) act.finish(succeeded=False, result=result, event_handler=handler)
raise e raise
else: else:
act.finish(succeeded=True, event_handler=on_commit) act.finish(succeeded=True, event_handler=on_commit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment