Decorators¶
- lanyard.http.decorator.handle_http_error(func)[source]¶
Decorator for handling HTTP errors in async methods.
Works when the
raise_for_statusattribute isTrue.- Parameters:
func (Callable[[...], Awaitable[HTTPResponse]]) – An async method returning an HTTPResponse
- Raises:
HTTPResponseError – If an unknown HTTP error occurs
HTTPClientError – If an unknown HTTP client error occurs (4xx)
HTTPServerError – If an unknown HTTP server error occurs (5xx)
NotFoundError – If an HTTP error with code 404 occurs
UnauthorizedError – If an HTTP error with code 401 occurs
- Returns:
A decorated function that handles HTTP errors
- Return type:
Callable[[…], Coroutine[Any, Any, HTTPResponse]]