diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-11-19 03:10:03 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-11-19 03:10:03 +0000 |
commit | 3f6a251faf324209247a868c91a9bacdea427db1 (patch) | |
tree | e8789dd5b97a4d62c342016c045210df03865ed8 /rdiff-backup/rdiff_backup/robust.py | |
parent | 3f7215648bac76bbdba0ac6dcbf608db2919877c (diff) | |
download | rdiff-backup-3f6a251faf324209247a868c91a9bacdea427db1.tar.gz |
Error reporting cleanup
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@684 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/robust.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/robust.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py index 67221e3..4fa8e6c 100644 --- a/rdiff-backup/rdiff_backup/robust.py +++ b/rdiff-backup/rdiff_backup/robust.py @@ -19,8 +19,8 @@ """Catch various exceptions given system call""" -import errno, signal -import librsync, C, static, rpath, Globals, log, statistics +import errno, signal, exceptions +import librsync, C, static, rpath, Globals, log, statistics, connection def check_common_error(error_handler, function, args = []): """Apply function to args, if error, run error_handler on exception @@ -38,7 +38,8 @@ def check_common_error(error_handler, function, args = []): if conn is not None: conn.statistics.record_error() if error_handler: return error_handler(exc, *args) else: return None - log.Log.exception(1, 2) + if is_routine_fatal(exc): log.Log.exception(1, 6) + else: log.Log.exception(1, 2) raise def catch_error(exc): @@ -59,6 +60,22 @@ def catch_error(exc): return 1 return 0 +def is_routine_fatal(exc): + """Return string if exception is non-error unrecoverable, None otherwise + + Used to suppress a stack trace for exceptions like keyboard + interrupts or connection drops. Return value is string to use as + an exit message. + + """ + if isinstance(exc, exceptions.KeyboardInterrupt): + return "User abort" + elif isinstance(exc, connection.ConnectionError): + return "Lost connection to the remote system" + elif isinstance(exc, SignalException): + return "Killed with signal %s" % (exc,) + return None + def get_error_handler(error_type): """Return error handler function that can be used above |