Skip to content

Commit dada006

Browse files
committed
Add base exception
All exceptions from this library inherit from this exception. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 53f784b commit dada006

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
## New Features
1212

13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
13+
* A new base exception `frequenz.channels.Error` was added. All exceptions from
14+
this library inherit from this exception.
1415

1516
## Bug Fixes
1617

src/frequenz/channels/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
3939
Exception classes:
4040
41+
* [Error][frequenz.channels.Error]: Base class for all errors in this
42+
library.
43+
4144
* [ChannelError][frequenz.channels.ChannelError]: Base class for all errors
4245
related to channels.
4346
@@ -47,7 +50,14 @@
4750

4851
from . import util
4952
from ._anycast import Anycast
50-
from ._base_classes import ChannelClosedError, ChannelError, Peekable, Receiver, Sender
53+
from ._base_classes import (
54+
ChannelClosedError,
55+
ChannelError,
56+
Error,
57+
Peekable,
58+
Receiver,
59+
Sender,
60+
)
5161
from ._bidirectional import Bidirectional
5262
from ._broadcast import Broadcast
5363

@@ -57,6 +67,7 @@
5767
"Broadcast",
5868
"ChannelClosedError",
5969
"ChannelError",
70+
"Error",
6071
"Peekable",
6172
"Receiver",
6273
"Sender",

src/frequenz/channels/_base_classes.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,22 @@
1212
U = TypeVar("U")
1313

1414

15-
class ChannelError(RuntimeError):
15+
class Error(RuntimeError):
16+
"""Base error.
17+
18+
All exceptions generated by this library inherit from this exception.
19+
"""
20+
21+
def __init__(self, message: Any):
22+
"""Create a ChannelError instance.
23+
24+
Args:
25+
message: An error message.
26+
"""
27+
super().__init__(message)
28+
29+
30+
class ChannelError(Error):
1631
"""Base channel error.
1732
1833
All exceptions generated by channels inherit from this exception.

0 commit comments

Comments
 (0)