mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
parent
f8808dba9b
commit
450e71f086
@ -122,6 +122,14 @@ class NotFound(HTTPException):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class DiscordServerError(HTTPException):
|
||||||
|
"""Exception that's thrown for when a 500 range status code occurs.
|
||||||
|
|
||||||
|
Subclass of :exc:`HTTPException`.
|
||||||
|
|
||||||
|
.. versionadded:: 1.5
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
class InvalidData(ClientException):
|
class InvalidData(ClientException):
|
||||||
"""Exception that's raised when the library encounters unknown
|
"""Exception that's raised when the library encounters unknown
|
||||||
|
@ -33,7 +33,7 @@ import weakref
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from .errors import HTTPException, Forbidden, NotFound, LoginFailure, GatewayNotFound
|
from .errors import HTTPException, Forbidden, NotFound, LoginFailure, DiscordServerError, GatewayNotFound
|
||||||
from .gateway import DiscordClientWebSocketResponse
|
from .gateway import DiscordClientWebSocketResponse
|
||||||
from . import __version__, utils
|
from . import __version__, utils
|
||||||
|
|
||||||
@ -252,6 +252,9 @@ class HTTPClient:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
# We've run out of retries, raise.
|
# We've run out of retries, raise.
|
||||||
|
if r.status >= 500:
|
||||||
|
raise DiscordServerError(r, data)
|
||||||
|
|
||||||
raise HTTPException(r, data)
|
raise HTTPException(r, data)
|
||||||
|
|
||||||
async def get_from_cdn(self, url):
|
async def get_from_cdn(self, url):
|
||||||
|
@ -34,7 +34,7 @@ from urllib.parse import quote as _uriquote
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .errors import InvalidArgument, HTTPException, Forbidden, NotFound
|
from .errors import InvalidArgument, HTTPException, Forbidden, NotFound, DiscordServerError
|
||||||
from .enums import try_enum, WebhookType
|
from .enums import try_enum, WebhookType
|
||||||
from .user import BaseUser, User
|
from .user import BaseUser, User
|
||||||
from .asset import Asset
|
from .asset import Asset
|
||||||
@ -241,7 +241,10 @@ class AsyncWebhookAdapter(WebhookAdapter):
|
|||||||
raise NotFound(r, response)
|
raise NotFound(r, response)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(r, response)
|
raise HTTPException(r, response)
|
||||||
|
|
||||||
# no more retries
|
# no more retries
|
||||||
|
if r.status >= 500:
|
||||||
|
raise DiscordServerError(r, response)
|
||||||
raise HTTPException(r, response)
|
raise HTTPException(r, response)
|
||||||
|
|
||||||
async def handle_execution_response(self, response, *, wait):
|
async def handle_execution_response(self, response, *, wait):
|
||||||
@ -342,7 +345,10 @@ class RequestsWebhookAdapter(WebhookAdapter):
|
|||||||
raise NotFound(r, response)
|
raise NotFound(r, response)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(r, response)
|
raise HTTPException(r, response)
|
||||||
|
|
||||||
# no more retries
|
# no more retries
|
||||||
|
if r.status >= 500:
|
||||||
|
raise DiscordServerError(r, response)
|
||||||
raise HTTPException(r, response)
|
raise HTTPException(r, response)
|
||||||
|
|
||||||
def handle_execution_response(self, response, *, wait):
|
def handle_execution_response(self, response, *, wait):
|
||||||
|
@ -2902,6 +2902,8 @@ The following exceptions are thrown by the library.
|
|||||||
|
|
||||||
.. autoexception:: NotFound
|
.. autoexception:: NotFound
|
||||||
|
|
||||||
|
.. autoexception:: DiscordServerError
|
||||||
|
|
||||||
.. autoexception:: InvalidData
|
.. autoexception:: InvalidData
|
||||||
|
|
||||||
.. autoexception:: InvalidArgument
|
.. autoexception:: InvalidArgument
|
||||||
@ -2931,3 +2933,4 @@ Exception Hierarchy
|
|||||||
- :exc:`HTTPException`
|
- :exc:`HTTPException`
|
||||||
- :exc:`Forbidden`
|
- :exc:`Forbidden`
|
||||||
- :exc:`NotFound`
|
- :exc:`NotFound`
|
||||||
|
- :exc:`DiscordServerError`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user