MCPcopy
hub / github.com/Rapptz/discord.py / HTTPException

Class HTTPException

discord/errors.py:113–155  ·  view source on GitHub ↗

Exception that's raised when an HTTP request operation fails. Attributes ------------ response: :class:`aiohttp.ClientResponse` The response of the failed HTTP request. This is an instance of :class:`aiohttp.ClientResponse`. In some cases this could also be a :cl

Source from the content-addressed store, hash-verified

111
112
113class HTTPException(DiscordException):
114 """Exception that's raised when an HTTP request operation fails.
115
116 Attributes
117 ------------
118 response: :class:`aiohttp.ClientResponse`
119 The response of the failed HTTP request. This is an
120 instance of :class:`aiohttp.ClientResponse`. In some cases
121 this could also be a :class:`requests.Response`.
122
123 text: :class:`str`
124 The text of the error. Could be an empty string.
125 status: :class:`int`
126 The status code of the HTTP request.
127 code: :class:`int`
128 The Discord specific error code for the failure.
129 """
130
131 def __init__(self, response: _ResponseType, message: Optional[Union[str, Dict[str, Any]]]):
132 self.response: _ResponseType = response
133 self.status: int = response.status # type: ignore # This attribute is filled by the library even if using requests
134 self.code: int
135 self.text: str
136 if isinstance(message, dict):
137 self.code = message.get('code', 0)
138 base = message.get('message', '')
139 errors = message.get('errors')
140 self._errors: Optional[Dict[str, Any]] = errors
141 if errors:
142 errors = _flatten_error_dict(errors)
143 helpful = '\n'.join('In %s: %s' % t for t in errors.items())
144 self.text = base + '\n' + helpful
145 else:
146 self.text = base
147 else:
148 self.text = message or ''
149 self.code = 0
150
151 fmt = '{0.status} {0.reason} (error code: {1})'
152 if len(self.text):
153 fmt += ': {2}'
154
155 super().__init__(fmt.format(self.response, self.code, self.text))
156
157
158class RateLimited(DiscordException):

Callers 4

requestMethod · 0.85
get_from_cdnMethod · 0.85
requestMethod · 0.85
requestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…