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

improved error handling when fetching exchange rate from UPbit #3361

Merged
merged 1 commit into from
Jul 19, 2021

Conversation

belikor
Copy link
Contributor

@belikor belikor commented Jul 13, 2021

If the error is not handled, the running daemon will continuously print the following error message:

Traceback (most recent call last):
  File "lbry/extras/daemon/exchange_rate_manager.py", line 77, in get_rate
  File "lbry/extras/daemon/exchange_rate_manager.py", line 189, in get_rate_from_response
KeyError: 0

This started happening when the UPBit exchange decided to delist the LBC coin.

Normally json_response should be a dictionary, not a list, so json_response[0] causes an error.

By checking for the 'error' key, we can raise the proper exception.

Once this is done, the message will be a warning, not a traceback.

WARNING  lbry.extras.daemon.exchange_rate_manager:92: Failed to get exchange rate from UPbit: result not found

This addresses the second error in #3287.

…nse`

If the error is not handled, the running daemon will continuously
print the following error message:
```
Traceback (most recent call last):
  File "lbry/extras/daemon/exchange_rate_manager.py", line 77, in get_rate
  File "lbry/extras/daemon/exchange_rate_manager.py", line 189, in get_rate_from_response
KeyError: 0
```

This started happening when the UPBit exchange decided to delist
the LBC coin.

Normally `json_response` should be a dictionary, not a list,
so `json_response[0]` causes an error.

By checking for the `'error'` key, we can raise the proper exception.

Once this is done, the message will be a warning, not a traceback.
```
WARNING  lbry.extras.daemon.exchange_rate_manager:92:
Failed to get exchange rate from UPbit: result not found
```
@eukreign eukreign changed the title exchange_rate_manager: raise exception if 'error' is in json_response improved error handling when fetching exchange rate from UPbit Jul 19, 2021
@eukreign eukreign added area: network type: improvement Existing (or partially existing) functionality needs to be changed labels Jul 19, 2021
@eukreign eukreign merged commit b7791d2 into lbryio:master Jul 19, 2021
@belikor belikor deleted the fix-UPbit-exception branch July 19, 2021 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: network type: improvement Existing (or partially existing) functionality needs to be changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants