|
17 | 17 | # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
|
19 | 19 | from collections.abc import Sequence |
20 | | -from typing import Callable, Optional |
| 20 | +from typing import Callable, Optional, Union |
21 | 21 |
|
22 | | -import pyrogram |
23 | 22 | from pyrogram.filters import Filter |
24 | | -from pyrogram.types import Update |
25 | 23 |
|
26 | 24 | from .handler import Handler |
27 | 25 |
|
@@ -71,19 +69,17 @@ class ErrorHandler(Handler): |
71 | 69 | :obj:`~pyrogram.raw.types.Channel` mentioned in the update. |
72 | 70 | You can access extra info about the chat (such as *title*, *participants_count*, etc...) |
73 | 71 | by using the IDs you find in the *update* argument (e.g.: *chats[1701277281]*). |
74 | | -
|
75 | 72 | """ |
76 | 73 |
|
77 | 74 | def __init__( |
78 | 75 | self, |
79 | 76 | callback: Callable, |
80 | 77 | filters: Optional[Filter] = None, |
81 | | - exceptions: Optional[type[Exception] | Sequence[type[Exception]]] = None |
| 78 | + exceptions: Optional[Union[Exception, Sequence[Exception]]] = None, |
82 | 79 | ): |
83 | 80 | super().__init__(callback, filters) |
84 | 81 |
|
85 | | - self.exceptions: tuple[Exception] = ( |
86 | | - tuple(exceptions) |
87 | | - if isinstance(exceptions, Sequence) |
88 | | - else exceptions or (Exception,) |
89 | | - ) |
| 82 | + exceptions = exceptions or Exception |
| 83 | + |
| 84 | + is_iterable = not isinstance(exceptions, Exception) |
| 85 | + self.exceptions = list(exceptions) if is_iterable else [exceptions] |
0 commit comments