diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-12-03 12:56:21 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-12-03 12:56:21 +0000 |
commit | 086c7d6a0d822e7ca407bbb52a107538124b75b5 (patch) | |
tree | 7549081e42931799aea3d48b99e54563266f6592 | |
parent | b79121abfe1a3c04af0b77855c9f45a03cbc8332 (diff) | |
download | larch-086c7d6a0d822e7ca407bbb52a107538124b75b5.tar.gz |
Optionally add original exception to NodeMissing
-rw-r--r-- | larch/nodestore.py | 11 | ||||
-rw-r--r-- | larch/nodestore_disk.py | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/larch/nodestore.py b/larch/nodestore.py index 82bcfbc..fb0abe0 100644 --- a/larch/nodestore.py +++ b/larch/nodestore.py @@ -21,9 +21,14 @@ class NodeMissing(larch.Error): '''A node cannot be found from a NodeStore.''' - def __init__(self, node_store, node_id): - self.msg = ('Node %d cannot be found in the node store %s' % - (node_id, node_store)) + def __init__(self, node_store, node_id, error=None): + if error is None: + error_msg = '' + else: + error_msg = (': %s: %s: %s' % + (error.errno, error.strerror, error.filename)) + self.msg = ('Node %d cannot be found in the node store %s%s' % + (node_id, node_store, error_msg)) class NodeTooBig(larch.Error): diff --git a/larch/nodestore_disk.py b/larch/nodestore_disk.py index 65c5f93..197a411 100644 --- a/larch/nodestore_disk.py +++ b/larch/nodestore_disk.py @@ -233,10 +233,10 @@ class NodeStoreDisk(larch.NodeStore): try: encoded = self.journal.cat(name) except (IOError, OSError), e: - logging.error('Error reading node: %s: %s: %s' % + logging.debug('Error reading node: %s: %s: %s' % (e.errno, e.strerror, e.filename or name)) logging.debug(traceback.format_exc()) - raise larch.NodeMissing(self.dirname, node_id) + raise larch.NodeMissing(self.dirname, node_id, error=e) else: node = self.codec.decode(encoded) node.frozen = True |