Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/pyblu/errors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from collections.abc import Awaitable, Callable
from collections.abc import Callable
from typing import ParamSpec, TypeVar

from functools import wraps

import aiohttp

__all__ = ["PlayerError", "PlayerUnreachableError", "PlayerUnexpectedResponseError"]

P = ParamSpec("P")
Expand Down Expand Up @@ -38,16 +36,3 @@ def wrapped(*args: P.args, **kwargs: P.kwargs) -> R:
raise PlayerUnexpectedResponseError(f"Unexpected response from player: {e}") from e

return wrapped


def _wrap_in_unreachable_error(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]:
@wraps(func)
async def wrapped(*args: P.args, **kwargs: P.kwargs) -> R:
try:
return await func(*args, **kwargs)
except TimeoutError as e:
raise PlayerUnreachableError(f"Timout during request: {e}") from e
except aiohttp.ClientConnectionError as e:
raise PlayerUnreachableError(f"Connection error: {e}") from e

return wrapped
Loading
Loading