summaryrefslogtreecommitdiff
path: root/ick2
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-07-09 18:37:12 +0300
committerLars Wirzenius <liw@liw.fi>2018-07-09 18:37:12 +0300
commitecc0b99d17c67a16cf20344e3f12a9c249a78c3a (patch)
tree571d44c3d966b9add9dcda1c6ba3406d079b9423 /ick2
parent90a9fd9cbdc18adf9c8d4a1aa76ee29943c3bb19 (diff)
downloadick2-ecc0b99d17c67a16cf20344e3f12a9c249a78c3a.tar.gz
Change: when raising NotFound, optionally say which resource
Diffstat (limited to 'ick2')
-rw-r--r--ick2/persistent.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/ick2/persistent.py b/ick2/persistent.py
index 4b216b3..535bdc0 100644
--- a/ick2/persistent.py
+++ b/ick2/persistent.py
@@ -95,7 +95,7 @@ class FilePersistentState(PersistentStateInterface):
def get_resource(self, kind, rid):
filename = self._filename(kind, rid)
if not os.path.exists(filename):
- raise ick2.NotFound()
+ raise ick2.NotFound(kind=kind, rid=rid)
with open(filename, 'r') as f:
as_dict = yaml.safe_load(f)
return resource_from_dict(as_dict)
@@ -116,8 +116,10 @@ class FilePersistentState(PersistentStateInterface):
class NotFound(Exception):
- def __init__(self):
- super().__init__('Resource not found')
+ def __init__(self, kind=None, rid=None):
+ super().__init__(
+ 'Resource {}:{} not found'.format(
+ kind or "unknown", rid or "unknown"))
class Resource: # pragma: no cover