Closed jlu5 closed 3 years ago
From discussion on IRC, without this patch getting the implicitly chained error is also possible via __context__
instead of __cause__
. But this is a fairly clear case of exception chaining, so we can be explicit about it. This also makes the traceback slightly clearer:
13:32:10 <+jlu5> implicit: During handling of the above exception, another exception occurred:
13:32:10 <+jlu5> explicit: The above exception was the direct cause of the following exception:
Note: This uses a Python 3 specific syntax, which means that the minisix usage in utils.web probably isn't useful anymore.
A lot of APIs, including LastFM and GitHub, serve detailed API errors in the body text even if the request returned an error. This allows plugins to track HTTP errors returned from urllib and present these detailed messages (although the syntax to do so isn't the prettiest).
An example with my LastFM plugin:
Before, the plugin would show generic errors like
Error: HTTP Error 400: Bad Request
. With this patch it can show the source error, likeError: LastFM API Error 10: Invalid API key - You must be granted a valid key by last.fm