koreanbots.errors의 소스 코드

from typing import Any, Dict, Type, Union


[문서]class KoreanbotsException(Exception): pass
[문서]class AuthorizeError(KoreanbotsException): pass
[문서]class HTTPException(KoreanbotsException): def __init__(self, code: Any, message: Union[Any, Dict[str, Any]]): self.status = code if isinstance(message, dict): self.status = message.get("code", self.status) self.error = message.get("message", "KoreanbotsException") else: self.error = message super().__init__(f"{self.status} {self.error}")
[문서]class BadRequest(HTTPException): pass
[문서]class Forbidden(HTTPException): pass
[문서]class NotFound(HTTPException): pass
ERROR_MAPPING: Dict[int, Type[HTTPException]] = { 400: BadRequest, 403: Forbidden, 404: NotFound, }