Skip to content

Commit

Permalink
nav() now displays some debugging information on KeyError (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
linsomniac committed Mar 1, 2024
1 parent 6365e23 commit 13701c4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ytmusicapi/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 13701c4

Please sign in to comment.