Skip to content

Commit 8e397ff

Browse files
committed
Refactor error handling
1 parent 1e44e45 commit 8e397ff

2 files changed

Lines changed: 65 additions & 187 deletions

File tree

src/pyblu/errors.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from collections.abc import Awaitable, Callable
1+
from collections.abc import Callable
22
from typing import ParamSpec, TypeVar
33

44
from functools import wraps
55

6-
import aiohttp
7-
86
__all__ = ["PlayerError", "PlayerUnreachableError", "PlayerUnexpectedResponseError"]
97

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

4038
return wrapped
41-
42-
43-
def _wrap_in_unreachable_error(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]:
44-
@wraps(func)
45-
async def wrapped(*args: P.args, **kwargs: P.kwargs) -> R:
46-
try:
47-
return await func(*args, **kwargs)
48-
except TimeoutError as e:
49-
raise PlayerUnreachableError(f"Timout during request: {e}") from e
50-
except aiohttp.ClientConnectionError as e:
51-
raise PlayerUnreachableError(f"Connection error: {e}") from e
52-
53-
return wrapped

0 commit comments

Comments
 (0)