Skip to content

Commit 851b0c7

Browse files
Update error_handler.py
1 parent f23d9b0 commit 851b0c7

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

pyrogram/handlers/error_handler.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from collections.abc import Sequence
20-
from typing import Callable, Optional
20+
from typing import Callable, Optional, Union
2121

22-
import pyrogram
2322
from pyrogram.filters import Filter
24-
from pyrogram.types import Update
2523

2624
from .handler import Handler
2725

@@ -71,19 +69,17 @@ class ErrorHandler(Handler):
7169
:obj:`~pyrogram.raw.types.Channel` mentioned in the update.
7270
You can access extra info about the chat (such as *title*, *participants_count*, etc...)
7371
by using the IDs you find in the *update* argument (e.g.: *chats[1701277281]*).
74-
7572
"""
7673

7774
def __init__(
7875
self,
7976
callback: Callable,
8077
filters: Optional[Filter] = None,
81-
exceptions: Optional[type[Exception] | Sequence[type[Exception]]] = None
78+
exceptions: Optional[Union[Exception, Sequence[Exception]]] = None,
8279
):
8380
super().__init__(callback, filters)
8481

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

Comments
 (0)