Improve internal apis

This commit is contained in:
Markus Unterwaditzer 2015-01-24 16:38:01 +01:00
parent 76c7f034a7
commit 500de6f081
3 changed files with 13 additions and 6 deletions

View file

@ -16,7 +16,7 @@ def catch_errors(f):
try:
f(*a, **kw)
except:
if not handle_cli_error():
handle_cli_error()
sys.exit(1)
return inner

View file

@ -70,7 +70,7 @@ def sync_collection(wq, pair_name, collection, config_a, config_b,
force_delete=force_delete
)
except:
if not handle_cli_error(status_name):
handle_cli_error(status_name)
raise JobFailed()
save_status(general['status_path'], pair_name, collection,

View file

@ -44,6 +44,13 @@ class JobFailed(RuntimeError):
def handle_cli_error(status_name='sync'):
'''
Print a useful error message for the current exception.
This is supposed to catch all exceptions, and should never raise any
exceptions itself.
'''
try:
raise
except CliError as e:
@ -480,7 +487,7 @@ class WorkerQueue(object):
try:
func(wq=self)
except Exception as e:
if not _handle_cli_error():
_handle_cli_error()
self._exceptions.append(e)
finally:
self._queue.task_done()