Skip to content

Commit cb0ed1e

Browse files
committed
Don't inherit from BaseException
According to Python, users should not inherit from `BaseException`, so we just inherit from `channels.Error` instead. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent e7b98d1 commit cb0ed1e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
- The `map()` function now takes a positional-only argument, if you were using `receiver.map(call=fun)` you should replace it with `receiver.map(func)`.
5050

51+
* `SelectError` now inherits from `channels.Error` instead of `BaseException`, so you should be able to catch it with `except Exception:` or `except channels.Error:`.
52+
5153
* `Selected`
5254

5355
- The `value` property was renamed to `message`.

src/frequenz/channels/_select.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
If this happens, it will raise an
4444
[`UnhandledSelectedError`][frequenz.channels.UnhandledSelectedError] exception.
4545
46-
Not handling a receiver is considered a programming error. Because of this, the
47-
exception is a subclass of [`BaseException`][BaseException] instead of
48-
[`Exception`][Exception]. This means that it will not be caught by [`except
49-
Exception`][Exception] blocks.
50-
5146
If for some reason you want to ignore a received message, just add the receiver to
5247
the if-chain and do nothing with the message:
5348
@@ -140,6 +135,7 @@
140135
from collections.abc import AsyncIterator
141136
from typing import Any, Generic, TypeGuard, TypeVar
142137

138+
from ._exceptions import Error
143139
from ._receiver import Receiver, ReceiverStoppedError
144140

145141
_T = TypeVar("_T")
@@ -277,7 +273,7 @@ def selected_from(
277273
return handled
278274

279275

280-
class SelectError(BaseException):
276+
class SelectError(Error):
281277
"""An error that happened during a [`select()`][frequenz.channels.select] operation.
282278
283279
This exception is raised when a `select()` iteration fails. It is raised as

0 commit comments

Comments
 (0)