decred / tinydecred

Python tools for Decred
ISC License
27 stars 14 forks source link

test: refactor util/tinyhttp.py #138

Closed teknico closed 4 years ago

teknico commented 4 years ago

Refactor util/tinyhttp.py and add tests for it. Part of #70.

JoeGruffins commented 4 years ago

Actually, something that's bothered me for a while

 File "/home/joe/git/tinydecred/decred/decred/util/tinyhttp.py", line 40, in request
    raw = urlrequest.urlopen(req, context=context).read().decode()
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

Is this the most unhelpful error message ever? What's it even mean? I see it all the time recently. Is there a way to make it output useful information?

teknico commented 4 years ago

Is this the most unhelpful error message ever? What's it even mean? I see it all the time recently. Is there a way to make it output useful information?

The string representation of the original error should have been right before that traceback.

I just changed the output of the dcr.util.formatTraceback function to clarify it a little.

buck54321 commented 4 years ago

Notice that's not a DecredError. I been trying to catch that exception for a while, but haven't figured out how.