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

NameError: name 'THROW_EXCEPTION_ON_ERROR' is not defined #25

Open
sunnyking opened this issue Jan 14, 2021 · 2 comments
Open

NameError: name 'THROW_EXCEPTION_ON_ERROR' is not defined #25

sunnyking opened this issue Jan 14, 2021 · 2 comments

Comments

@sunnyking
Copy link
Member

Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/pyvsystems/account.py", line 62, in balance
resp = self.wrapper.request('/addresses/balance/%s%s' % (self.address, confirmations_str))
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/pyvsystems/wrapper.py", line 36, in request
return requests.get(url, headers=headers, timeout=self.timeout).json()
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/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)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 409, in
loop.run_until_complete(GemmerApp().execute())
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "main.py", line 402, in run_wrapper
await self.async_run(async_lib='asyncio')
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/app.py", line 962, in async_run
await async_runTouchApp(async_lib=async_lib)
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/base.py", line 605, in async_runTouchApp
await EventLoop.async_mainloop()
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/base.py", line 362, in async_mainloop
await self.async_idle()
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/base.py", line 426, in async_idle
await Clock.async_tick()
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/clock.py", line 740, in async_tick
self.post_idle(ts, current)
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/kivy/clock.py", line 776, in post_idle
self._process_events()
File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick
File "/home/ubuntu/Github/virtualeconomy/gemmer/gui/tasks.py", line 101, in _execute
balance = app.balance()
File "main.py", line 372, in balance
response = self.wallet.balance() # fetch address balance
File "/home/ubuntu/Github/virtualeconomy/gemmer/gemmer/wallet.py", line 211, in balance
return self.COIN.client.balance(self.address())
File "/home/ubuntu/Github/virtualeconomy/gemmer/gemmer/vnode.py", line 48, in balance
"confirmed": AccountV(chain=self.CHAIN, address=address).balance(),
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/pyvsystems/account.py", line 66, in balance
throw_error(msg, NetworkException)
File "/home/ubuntu/.local/share/virtualenvs/gemmer-q4Xooie9/lib/python3.7/site-packages/pyvsystems/error.py", line 54, in throw_error
if THROW_EXCEPTION_ON_ERROR:
NameError: name 'THROW_EXCEPTION_ON_ERROR' is not defined

@sunnyking
Copy link
Member Author

height() call can let JSONDecodeError raise correctly
balance() call hit NameError instead
pyvsystems 0.2.1

@sunnyking
Copy link
Member Author

sunnyking commented Jan 14, 2021

Another thing, the JSONDecodeError in this case, can also be avoided by checking the http response code and mime type before attempting json decode. Successful response is like:

HTTP request sent, awaiting response... 200 OK
Length: 25 [application/json]

while in this occurrence:

--2021-01-14 16:37:03--  https://test.v.systems/api/blocks/height
Connecting to test.v.systems (test.v.systems)|104.26.9.50|:443... connected.
HTTP request sent, awaiting response... 502 Bad Gateway
2021-01-14 16:37:04 ERROR 502: Bad Gateway.

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

1 participant