aboutsummaryrefslogtreecommitdiff
path: root/discord/errors.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-04 00:16:34 -0500
committerRapptz <[email protected]>2015-12-04 00:16:34 -0500
commitf197c345832ff09fe081b7cb542de9288d0b780e (patch)
tree868d84f0708f9ceb9d3395bfd0223ef3c59a2514 /discord/errors.py
parentPoint to the docs in the README and clear up notes on breaking changes (diff)
downloaddiscord.py-f197c345832ff09fe081b7cb542de9288d0b780e.tar.xz
discord.py-f197c345832ff09fe081b7cb542de9288d0b780e.zip
Begin working on asyncio port.
Diffstat (limited to 'discord/errors.py')
-rw-r--r--discord/errors.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/discord/errors.py b/discord/errors.py
index abe0bff9..0d75fb53 100644
--- a/discord/errors.py
+++ b/discord/errors.py
@@ -24,11 +24,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
-try:
- import http.client as httplib
-except ImportError:
- import httplib
-
class DiscordException(Exception):
"""Base exception class for discord.py
@@ -56,28 +51,19 @@ class HTTPException(DiscordException):
.. attribute:: response
The response of the failed HTTP request. This is an
- instance of `requests.Response`__.
+ instance of `aiohttp.ClientResponse`__.
- __ http://docs.python-requests.org/en/latest/api/#requests.Response
+ __ http://aiohttp.readthedocs.org/en/stable/client_reference.html#aiohttp.ClientResponse
"""
def __init__(self, response, message=None):
self.response = response
- if message is None:
- message = httplib.responses.get(response.status_code, 'HTTP error')
-
- message = '{0} (status code: {1.response.status_code})'.format(message, self)
-
- try:
- data = response.json()
- response_error = data['message']
- if response_error:
- message = '{}: {}'.format(message, response_error)
- except:
- pass
+ fmt = '{0.reason} (status code: {0.status})'
+ if message:
+ fmt = fmt + ': {1}'
- super(HTTPException, self).__init__(message)
+ super().__init__(fmt.format(self.response, message))
class InvalidArgument(ClientException):
"""Exception that's thrown when an argument to a function