From 89db9b8b9ec77b3e8e73e2aa2df88edeb223a65c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 25 Jun 2015 23:57:38 +0200 Subject: [PATCH] improve at-end error logging always use archiver.print_error, so it goes to sys.stderr always say "Error: ..." for errors for rc != 0 always say "Exiting with failure status ..." catch all exceptions subclassing Exception, so we can log them in same way and set exit_code=1 --- borg/archiver.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 3cd588b84..4127067d7 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -866,19 +866,19 @@ def main(): try: exit_code = archiver.run(sys.argv[1:]) except Error as e: - traceback.print_exc() - archiver.print_error(e.get_message()) + archiver.print_error(e.get_message() + "\n%s" % traceback.format_exc()) exit_code = e.exit_code except RemoteRepository.RPCError as e: - print(e) + archiver.print_error('Error: Remote Exception.\n%s' % str(e)) + exit_code = 1 + except Exception: + archiver.print_error('Error: Local Exception.\n%s' % traceback.format_exc()) exit_code = 1 except KeyboardInterrupt: - traceback.print_exc() - archiver.print_error('Error: Keyboard interrupt') + archiver.print_error('Error: Keyboard interrupt.\n%s' % traceback.format_exc()) exit_code = 1 - else: - if exit_code: - archiver.print_error('Exiting with failure status due to previous errors') + if exit_code: + archiver.print_error('Exiting with failure status due to previous errors') sys.exit(exit_code) if __name__ == '__main__':