Skip to content

Commit

Permalink
FIX: do not wrap CancelledError into BackendError 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Oct 4, 2024
1 parent 7a89b24 commit e4aabd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion combadge/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __exit__( # type: ignore[misc]
/,
) -> None:
# Wrapping `CancelledError` breaks `asyncio.TaskGroup`.
if exc_value is not None and not isinstance(exc_type, CancelledError):
if exc_value is not None and not isinstance(exc_value, CancelledError):
raise cls(exc_value) from exc_value


Expand Down
17 changes: 17 additions & 0 deletions tests/core/test_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from asyncio import CancelledError

import pytest

from combadge.core.errors import BackendError


@pytest.mark.parametrize("inner_exception", [ValueError(42)])
def test_wrapped(inner_exception: BaseException) -> None:
with pytest.raises(BackendError), BackendError:
raise inner_exception


@pytest.mark.parametrize("inner_exception", [CancelledError()])
def test_non_wrapped(inner_exception: BaseException) -> None:
with pytest.raises(type(inner_exception)), BackendError:
raise inner_exception

0 comments on commit e4aabd0

Please sign in to comment.