You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In exceptions.py JSONPointerIndexError, JSONPointerKeyError, and JSONPointerTypeError use multiple inheritance to extend from both JSONPointerResolutionError, and IndexError, KeyError, and TypeError respectively.
Java doesn't have multiple class inheritance. I could get tricky with using interfaces to try to duplicate this, but first I wanted to ask what is your design goal with this class hierarchy? In test_json_pointer.py, you're catching the Python built-ins and not your custom Error classes. Is there a reason you are not just catching JSONPointerIndexError, JSONPointerKeyError, and JSONPointerTypeError?
Inheriting from IndexError, KeyError and TypeError was an afterthought and not part of the original design. I wanted to cater for Python users that might expect handling standard exceptions to work as if they're accessing a dictionary or list. A bit like being able to catch IndexOutOfBoundsException or a custom exception with an independent class hierarchy in Java.
Testing the standard exceptions in test_json_pointer.py and not those inheriting from JSONPointerResolutionError is an oversight on my part.
I think you could safely ignore multiple inheritance here and go with something like this:
The important part being that JSONPointerResolutionError and its subclasses only occur when resolving a JSON Pointer, not when parsing a JSON Pointer from a string (I can see one place where I'm failing to do this).
Depending on how strict you're being with your port, you could instead choose to follow Jackson's example and use a "missing" object to indicate the absence of a node instead of throwing exceptions, a bit like JsonNode.path() does, if that would make more sense to your average Java developer (it's been a long time since I wrote any Java 🤷♂️).
Cheers,
James
Repository owner locked and limited conversation to collaborators on Aug 3, 2025
Activity
jg-rp commentedon Aug 2, 2025
Hi Rob,
Inheriting from
IndexError,KeyErrorandTypeErrorwas an afterthought and not part of the original design. I wanted to cater for Python users that might expect handling standard exceptions to work as if they're accessing a dictionary or list. A bit like being able to catchIndexOutOfBoundsExceptionor a custom exception with an independent class hierarchy in Java.Testing the standard exceptions in
test_json_pointer.pyand not those inheriting fromJSONPointerResolutionErroris an oversight on my part.I think you could safely ignore multiple inheritance here and go with something like this:
The important part being that
JSONPointerResolutionErrorand its subclasses only occur when resolving a JSON Pointer, not when parsing a JSON Pointer from a string (I can see one place where I'm failing to do this).Depending on how strict you're being with your port, you could instead choose to follow Jackson's example and use a "missing" object to indicate the absence of a node instead of throwing exceptions, a bit like
JsonNode.path()does, if that would make more sense to your average Java developer (it's been a long time since I wrote any Java 🤷♂️).Cheers,
James