summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-01-22 06:39:55 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-01-22 06:53:33 +0100
commit6ef15afae90a8e925a5482d5a8ea2a98702d54fa (patch)
treef6ac87be842683d2fb5063ed27b3c38c09227632
parentmodules: Update rtems (diff)
downloadrtems-central-6ef15afae90a8e925a5482d5a8ea2a98702d54fa.tar.bz2
items: Improve identifier to item error message
-rw-r--r--rtemsspec/items.py11
-rw-r--r--rtemsspec/tests/test_items_itemcache.py3
2 files changed, 11 insertions, 3 deletions
diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 3a2d5e34..bcc7ed0a 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -502,13 +502,18 @@ class ItemMapper:
else:
uid, key_path = uid_key_path, "/_uid"
if uid == ".":
- if item is None:
- item = self._item
if prefix is None:
prefix = "/".join(self._prefix)
+ if item is None:
+ item = self._item
else:
- item = self._item.map(uid)
prefix = ""
+ try:
+ item = self._item.map(uid)
+ except KeyError as err:
+ msg = (f"item '{uid}' relative to {self._item.spec} "
+ f"specified by '{identifier}' does not exist")
+ raise ValueError(msg) from err
key_path = normalize_key_path(key_path, prefix)
value = item.get_by_normalized_key_path(key_path,
self.get_value_map(item))
diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py
index b1aba815..483c8d43 100644
--- a/rtemsspec/tests/test_items_itemcache.py
+++ b/rtemsspec/tests/test_items_itemcache.py
@@ -161,6 +161,9 @@ def test_item_mapper(tmpdir):
match = r"substitution for spec:/p using prefix 'blub' failed for text: \${}"
with pytest.raises(ValueError, match=match):
mapper.substitute("${}", item, "blub")
+ match = r"item 'boom' relative to spec:/p specified by 'boom:bam' does not exist"
+ with pytest.raises(ValueError, match=match):
+ mapper.map("boom:bam", item, "blub")
def test_empty_item_mapper():