Skip to content

Errors

AnilistError

AnilistError(*, message: str, status_code: int)

Bases: Exception

Base class for Anilist API errors, containing a message and status code.

Source code in src/pyanilist/_errors.py
def __init__(self, *, message: str, status_code: int):
    self._message = message
    self._status_code = status_code
    super().__init__(message)

message property

message: str

The error message returned by the API.

status_code property

status_code: int

The HTTP status code of the error response.

MediaNotFoundError

MediaNotFoundError()

Bases: AnilistError

Raised when a requested media item is not found.

Source code in src/pyanilist/_errors.py
def __init__(self) -> None:
    super().__init__(message="Not Found.", status_code=404)

NoMediaArgumentsError

NoMediaArgumentsError()

Bases: AnilistError

Raised when a Media query is made with no arguments provided.

Source code in src/pyanilist/_errors.py
def __init__(self) -> None:
    super().__init__(message="The Media query requires at least 1 argument.", status_code=400)

RateLimitError

RateLimitError(*, retry_after: int)

Bases: AnilistError

Raised when the API rate limit is exceeded.

Source code in src/pyanilist/_errors.py
def __init__(self, *, retry_after: int):
    self._retry_after = retry_after
    message = f"Too Many Requests. Please wait for {self.retry_after} seconds before your next request."
    super().__init__(message=message, status_code=429)

retry_after property

retry_after: int

The number of seconds to wait before making another request.