pokelance.exceptions ⚓︎

AudioNotFound(message, route, status) ⚓︎

Bases: NotFound

Exception raised when an audio is not found.

Parameters:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

  • status (int) –

    The status code of the exception.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    super().__init__(message, route, status)

create() ⚓︎

Creates an exception from the status code.

Source code in pokelance/exceptions.py
Python
def create(self) -> "HTTPException":
    """Creates an exception from the status code."""
    return get_exception(self.status)(self.message, self.route, self.status)

BadRequest(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when a bad request is made. [HTTP 400]

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

Forbidden(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when forbidden. [HTTP 403]

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

HTTPException(message, route, status) ⚓︎

Bases: PokeLanceException

Base exception class for HTTP exceptions.

Parameters:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

  • status (int) –

    The status code of the exception.

Attributes:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

  • status (int) –

    The status code of the exception.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

create() ⚓︎

Creates an exception from the status code.

Source code in pokelance/exceptions.py
Python
def create(self) -> "HTTPException":
    """Creates an exception from the status code."""
    return get_exception(self.status)(self.message, self.route, self.status)

ImageNotFound(message, route, status) ⚓︎

Bases: NotFound

Exception raised when an image is not found.

Parameters:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

  • status (int) –

    The status code of the exception.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    super().__init__(message, route, status)

create() ⚓︎

Creates an exception from the status code.

Source code in pokelance/exceptions.py
Python
def create(self) -> "HTTPException":
    """Creates an exception from the status code."""
    return get_exception(self.status)(self.message, self.route, self.status)

MethodNotAllowed(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when a method is not allowed. [HTTP 405]

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

NotFound(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when a resource is not found. [HTTP 404]

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

PokeLanceException(message, route) ⚓︎

Bases: Exception

Base exception class for PokeLance.

Parameters:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

Attributes:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route") -> None:
    self.message = message
    self.route = route
    super().__init__(message)

ResourceNotFound(message, route, status) ⚓︎

Bases: NotFound

Exception raised when a resource is not found.

Parameters:
  • message (str) –

    The message to display.

  • route (Route) –

    The route that caused the exception.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    super().__init__(message, route, status)

create() ⚓︎

Creates an exception from the status code.

Source code in pokelance/exceptions.py
Python
def create(self) -> "HTTPException":
    """Creates an exception from the status code."""
    return get_exception(self.status)(self.message, self.route, self.status)

Unauthorized(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when unauthorized. [HTTP 401]

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

UnknownError(message, route, status) ⚓︎

Bases: HTTPException

Exception raised when an unknown error occurs.

Source code in pokelance/exceptions.py
Python
def __init__(self, message: str, route: "Route", status: int) -> None:
    self.status = status
    super().__init__(message, route)

get_exception(status) ⚓︎

Gets an exception from the status code.

Parameters:
  • status (int) –

    The status code.

Returns:
Source code in pokelance/exceptions.py
Python
def get_exception(status: int) -> t.Type[HTTPException]:
    """Gets an exception from the status code.

    Parameters
    ----------
    status: int
        The status code.

    Returns
    -------
    pokelance.exceptions.HTTPException
        The exception.
    """
    return CODES.get(status, UnknownError)