aboutsummaryrefslogtreecommitdiff
path: root/discord/utils.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-04 01:23:52 -0500
committerRapptz <[email protected]>2015-12-04 01:23:52 -0500
commit99254fdf965e71c929a4d64390fe83810bc2fb45 (patch)
tree966461eba1fd56faf897e85aca8d205b733a4dc8 /discord/utils.py
parentBegin working on asyncio port. (diff)
downloaddiscord.py-99254fdf965e71c929a4d64390fe83810bc2fb45.tar.xz
discord.py-99254fdf965e71c929a4d64390fe83810bc2fb45.zip
Add Forbidden and NotFound exceptions.
Diffstat (limited to 'discord/utils.py')
-rw-r--r--discord/utils.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/utils.py b/discord/utils.py
index 3e22c710..d2477696 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
from re import split as re_split
-from .errors import HTTPException, InvalidArgument
+from .errors import HTTPException, Forbidden, NotFound, InvalidArgument
import datetime
import asyncio
@@ -66,7 +66,12 @@ def _verify_successful_response(response):
success = code >= 200 and code < 300
if not success:
data = yield from response.json()
- raise HTTPException(response, data.get('message'))
+ message = data.get('message')
+ if code == 403:
+ raise Forbidden(response, message)
+ elif code == 404:
+ raise NotFound(response, message)
+ raise HTTPException(response, message)
def _get_mime_type_for_image(data):
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):