1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

remote: propagate Error.traceback correctly

This commit is contained in:
Marian Beermann 2017-05-31 18:48:48 +02:00
parent 4edf77788d
commit f8b48dc8d7
2 changed files with 9 additions and 1 deletions

View file

@ -4000,7 +4000,7 @@ def main(): # pragma: no cover
tb = "%s\n%s" % (traceback.format_exc(), sysinfo())
exit_code = e.exit_code
except RemoteRepository.RPCError as e:
important = e.exception_class not in ('LockTimeout', )
important = e.exception_class not in ('LockTimeout', ) and e.traceback
msgid = e.exception_class
tb_log_level = logging.ERROR if important else logging.DEBUG
if important:

View file

@ -253,8 +253,10 @@ def serve(self):
if dictFormat:
ex_short = traceback.format_exception_only(e.__class__, e)
ex_full = traceback.format_exception(*sys.exc_info())
ex_trace = True
if isinstance(e, Error):
ex_short = [e.get_message()]
ex_trace = e.traceback
if isinstance(e, (Repository.DoesNotExist, Repository.AlreadyExists, PathNotAllowed)):
# These exceptions are reconstructed on the client end in RemoteRepository.call_many(),
# and will be handled just like locally raised exceptions. Suppress the remote traceback
@ -269,6 +271,7 @@ def serve(self):
b'exception_args': e.args,
b'exception_full': ex_full,
b'exception_short': ex_short,
b'exception_trace': ex_trace,
b'sysinfo': sysinfo()})
except TypeError:
msg = msgpack.packb({MSGID: msgid,
@ -277,6 +280,7 @@ def serve(self):
for x in e.args],
b'exception_full': ex_full,
b'exception_short': ex_short,
b'exception_trace': ex_trace,
b'sysinfo': sysinfo()})
os_write(stdout_fd, msg)
@ -485,6 +489,10 @@ def get_message(self):
else:
return self.exception_class
@property
def traceback(self):
return self.unpacked.get(b'exception_trace', True)
@property
def exception_class(self):
return self.unpacked[b'exception_class'].decode()