mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-19 13:05:52 +00:00
Improve internal apis
This commit is contained in:
parent
76c7f034a7
commit
500de6f081
3 changed files with 13 additions and 6 deletions
|
|
@ -16,8 +16,8 @@ def catch_errors(f):
|
||||||
try:
|
try:
|
||||||
f(*a, **kw)
|
f(*a, **kw)
|
||||||
except:
|
except:
|
||||||
if not handle_cli_error():
|
handle_cli_error()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,8 @@ def sync_collection(wq, pair_name, collection, config_a, config_b,
|
||||||
force_delete=force_delete
|
force_delete=force_delete
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
if not handle_cli_error(status_name):
|
handle_cli_error(status_name)
|
||||||
raise JobFailed()
|
raise JobFailed()
|
||||||
|
|
||||||
save_status(general['status_path'], pair_name, collection,
|
save_status(general['status_path'], pair_name, collection,
|
||||||
data_type='items', data=status)
|
data_type='items', data=status)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@ class JobFailed(RuntimeError):
|
||||||
|
|
||||||
|
|
||||||
def handle_cli_error(status_name='sync'):
|
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:
|
try:
|
||||||
raise
|
raise
|
||||||
except CliError as e:
|
except CliError as e:
|
||||||
|
|
@ -480,8 +487,8 @@ class WorkerQueue(object):
|
||||||
try:
|
try:
|
||||||
func(wq=self)
|
func(wq=self)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not _handle_cli_error():
|
_handle_cli_error()
|
||||||
self._exceptions.append(e)
|
self._exceptions.append(e)
|
||||||
finally:
|
finally:
|
||||||
self._queue.task_done()
|
self._queue.task_done()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue