Decorators

lanyard.decorator.requires_token(func)[source]

A decorator that ensures that a token is present before making an httpx request.

Throws an exception when the token attribute is missing or is False.

Parameters:

func (Callable[[...], Awaitable[R]]) – Async method

Raises:

TokenRequiredError – Token is missing

Returns:

Decorated function that checks for the presence of a token

Return type:

Callable[[…], Coroutine[Any, Any, R]]

lanyard.decorator.handle_error(func)[source]

A decorator that handles certain HTTP errors and converts them into API Wrapper exceptions.

Parameters:

func (Callable[[...], Awaitable[R]]) – Async method to be decorated

Raises:

NoPermissionError – When the request returns Unauthorized status (401)

Returns:

Decorated function with error handling

Return type:

Callable[[…], Coroutine[Any, Any, R]]