Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling for wrong URL for client #353

Closed
mvadari opened this issue Feb 3, 2022 · 3 comments
Closed

Better error handling for wrong URL for client #353

mvadari opened this issue Feb 3, 2022 · 3 comments

Comments

@mvadari
Copy link
Collaborator

mvadari commented Feb 3, 2022

If you put in the wrong URL of a node for a client, the error that it returns is super opaque (it's a JSONDecodeError). We should return a better error/error message, so that it's clear that the user entered the wrong URL for the node.

@khancode
Copy link
Collaborator

@mvadari Can you share code to repro this?

@mvadari
Copy link
Collaborator Author

mvadari commented May 11, 2022

Here's one example:

>>> client = JsonRpcClient("https://s2.ripple.com:51233")
>>> client.request(ServerInfo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mvadari/Documents/xrpl-py/xrpl/clients/sync_client.py", line 28, in request
    return asyncio.run(self.request_impl(request))
  File "/Users/mvadari/.pyenv/versions/3.9.1/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/mvadari/.pyenv/versions/3.9.1/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/mvadari/Documents/xrpl-py/xrpl/asyncio/clients/json_rpc_base.py", line 39, in request_impl
    return json_to_response(response.json())
  File "/Users/mvadari/Documents/xrpl-py/.venv/lib/python3.9/site-packages/httpx/_models.py", line 1415, in json
    return jsonlib.loads(self.text, **kwargs)
  File "/Users/mvadari/.pyenv/versions/3.9.1/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Users/mvadari/.pyenv/versions/3.9.1/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/mvadari/.pyenv/versions/3.9.1/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@mvadari
Copy link
Collaborator Author

mvadari commented Oct 18, 2022

Resolved by #388

@mvadari mvadari closed this as completed Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants