summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-02-24 17:49:52 +0000
committerLars Wirzenius <liw@liw.fi>2013-02-24 17:49:52 +0000
commit21376a824071928cfb82afcbffc0db60b82751de (patch)
tree7789a62258cdcd62e2e978773b574a59479ede9d
parent669695c1fb3bdc8f6a169ddd2c1eb2bf10fb6833 (diff)
downloadlarch-21376a824071928cfb82afcbffc0db60b82751de.tar.gz
Improve error messages for missing nodes
-rw-r--r--NEWS1
-rw-r--r--larch/nodestore.py6
-rw-r--r--larch/nodestore_disk.py6
3 files changed, 8 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 02d4494..3eea7c2 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Version UNRELEASED
`NodeStore` and `NodeStoreMemory` now have a new first argument,
`allow_writes`, to make them compatible with the `NodeStoreDisk`
initialiser. Patch by Antoine Brenner.
+* Improved error messages for nodes that seem to be missing.
Version 1.20121216
------------------
diff --git a/larch/nodestore.py b/larch/nodestore.py
index dd9b536..70bcc93 100644
--- a/larch/nodestore.py
+++ b/larch/nodestore.py
@@ -21,10 +21,8 @@ class NodeMissing(larch.Error):
'''A node cannot be found from a NodeStore.'''
- def __init__(self, node_store, node_id, error=None):
- if error is None:
- error_msg = ''
- else:
+ def __init__(self, node_store, node_id, error=None, error_msg=''):
+ if error is not None:
error_msg = (': %s: %s: %s' %
(error.errno, error.strerror, error.filename))
self.msg = ('Node %s cannot be found in the node store %s%s' %
diff --git a/larch/nodestore_disk.py b/larch/nodestore_disk.py
index 6e8cd2f..dec41e1 100644
--- a/larch/nodestore_disk.py
+++ b/larch/nodestore_disk.py
@@ -258,7 +258,11 @@ class NodeStoreDisk(larch.NodeStore):
if self.journal.exists(name):
self.journal.remove(name)
elif not got_it:
- raise larch.NodeMissing(self.dirname, node_id)
+ raise larch.NodeMissing(
+ self.dirname,
+ node_id,
+ error_msg='attempted to remove node that is not '
+ 'in journal or in upload queue')
def list_nodes(self):
queued = self.upload_queue.list_ids()