always set __cause__ of translated exceptions

This commit is contained in:
Sam Schott 2020-04-05 13:21:04 +01:00
parent 0829495d2e
commit 61444e856d
2 changed files with 10 additions and 4 deletions

View File

@ -109,12 +109,12 @@ def to_maestral_error(dbx_path_arg=None, local_path_arg=None):
try:
return func(*args, **kwargs)
except dropbox.exceptions.DropboxException as exc:
raise dropbox_to_maestral_error(exc, dbx_path, local_path) from exc
raise dropbox_to_maestral_error(exc, dbx_path, local_path)
# catch connection errors first, they may inherit from OSError
except CONNECTION_ERRORS:
raise ConnectionError('Cannot connect to Dropbox')
except OSError as exc:
raise os_to_maestral_error(exc, dbx_path, local_path) from exc
raise os_to_maestral_error(exc, dbx_path, local_path)
return wrapper

View File

@ -216,7 +216,10 @@ def os_to_maestral_error(exc, dbx_path=None, local_path=None):
else:
return exc
return err_cls(title, text, dbx_path=dbx_path, local_path=local_path)
maestral_exc = err_cls(title, text, dbx_path=dbx_path, local_path=local_path)
maestral_exc.__cause__ = exc
return maestral_exc
def dropbox_to_maestral_error(exc, dbx_path=None, local_path=None):
@ -424,7 +427,10 @@ def dropbox_to_maestral_error(exc, dbx_path=None, local_path=None):
title = 'An unexpected error occurred'
text = exc.args[0]
return err_cls(title, text, dbx_path=dbx_path, local_path=local_path)
maestral_exc = err_cls(title, text, dbx_path=dbx_path, local_path=local_path)
maestral_exc.__cause__ = exc
return maestral_exc
def _get_write_error_msg(write_error):