Skip to content

Commit 09ba12f

Browse files
committed
fix on_error logic in routines
1 parent 358a3ed commit 09ba12f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

twitchio/ext/routines/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
T = TypeVar("T")
4040
CoroT: TypeAlias = Callable[..., Coroutine[Any, Any, Any]]
41-
ErrorT: TypeAlias = Callable[..., Coroutine[Any, Any, Any]]
4241

4342

4443
LOGGER: logging.Logger = logging.getLogger(__name__)
@@ -118,7 +117,7 @@ def __init__(
118117

119118
self._before_routine: CoroT | None = None
120119
self._after_routine: CoroT | None = None
121-
self._on_error: CoroT = self.on_error
120+
self._on_error: CoroT | None = None
122121

123122
self._stop_on_error: bool = stop_on_error
124123
self._should_stop: bool = False
@@ -172,6 +171,10 @@ def _can_cancel(self) -> bool:
172171
return self._task is not None and not self._task.done()
173172

174173
async def _call_error(self, error: Exception) -> None:
174+
if self._on_error is None:
175+
await self.on_error(error)
176+
return
177+
175178
if self._injected is not None:
176179
await self._on_error(self._injected, error)
177180
else:

0 commit comments

Comments
 (0)