nav() now displays some debugging information on KeyError (#540)
This commit is contained in:
parent
6365e23422
commit
13701c40b7
1 changed files with 3 additions and 4 deletions
|
|
@ -96,12 +96,11 @@ def nav(root: Dict, items: List[Any], none_if_absent: bool = False) -> Optional[
|
|||
try:
|
||||
for k in items:
|
||||
root = root[k]
|
||||
return root
|
||||
except Exception as err:
|
||||
except (KeyError, IndexError, TypeError) as e:
|
||||
if none_if_absent:
|
||||
return None
|
||||
else:
|
||||
raise err
|
||||
raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
|
||||
return root
|
||||
|
||||
|
||||
def find_object_by_key(object_list, key, nested=None, is_key=False):
|
||||
|
|
|
|||
Loading…
Reference in a new issue