diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2010-08-30 11:28:09 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2010-08-30 11:28:09 (GMT) |
commit | 9882d3d0145d34043d6717fd7a2855c51e3fb936 (patch) | |
tree | fdb7fdd75bcb2ba33985fc81a5101dbae77af77e | |
parent | 79cb03363928dcfe0520874ae0bf16316b815338 (diff) |
provide easier-to-understand error message if saving an entry fails
-rw-r--r-- | restore.py | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -77,6 +77,16 @@ class MalformedBundleException(Exception): pass +class SaveFailedException(Exception): + """Saving a data store entry failed.""" + + def __init__(self, exception, traceback_string): + message = _('Failed to save entry to data store') + Exception.__init__(self, message) + self.exception = exception + self.traceback_string = traceback_string + + if pre_086_toolbars: class StopButton(ToolButton): @@ -257,6 +267,8 @@ class AsyncRestore(gobject.GObject): message = unicode(exception).encode('utf-8') self._pipe_from_child.write(message+'\n') trace = unicode(traceback.format_exc()).encode('utf-8') + if hasattr(exception, 'traceback_string'): + trace += unicode(exception.traceback_string).encode('utf-8') self._pipe_from_child.write(trace) self._close_bundle() sys.exit(2) @@ -358,7 +370,12 @@ class AsyncRestore(gobject.GObject): metadata[name] = dbus.ByteArray(value) del file_paths[:] - self._save_entry(metadata, data_file_name) + try: + self._save_entry(metadata, data_file_name) + except Exception, exception: + logging.exception('_save_entry(%r, %r) failed', metadata, + data_file_name) + raise SaveFailedException(exception, traceback.format_exc()) def _close_bundle(self): """Ensure the bundle is closed.""" |