Skip to content

Commit 13701c4

Browse files
authored
nav() now displays some debugging information on KeyError (sigma67#540)
1 parent 6365e23 commit 13701c4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ytmusicapi/navigation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ def nav(root: Dict, items: List[Any], none_if_absent: bool = False) -> Optional[
9696
try:
9797
for k in items:
9898
root = root[k]
99-
return root
100-
except Exception as err:
99+
except (KeyError, IndexError, TypeError) as e:
101100
if none_if_absent:
102101
return None
103-
else:
104-
raise err
102+
raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
103+
return root
105104

106105

107106
def find_object_by_key(object_list, key, nested=None, is_key=False):

0 commit comments

Comments
 (0)