2525
2626if TYPE_CHECKING :
2727 import hydrogram
28+ from hydrogram .types import Update
2829
2930
3031class ErrorHandler (Handler ):
@@ -47,26 +48,29 @@ class ErrorHandler(Handler):
4748 client (:obj:`~hydrogram.Client`):
4849 The Client itself, useful when you want to call other API methods inside the error handler.
4950
50- error (``Exception``):
51- The error that was raised.
52-
5351 update (:obj:`~hydrogram.Update`):
5452 The update that caused the error.
53+
54+ error (``Exception``):
55+ The error that was raised.
5556 """
5657
5758 def __init__ (
58- self , callback : Callable , errors : type [Exception ] | Iterable [type [Exception ]] | None = None
59+ self ,
60+ callback : Callable ,
61+ errors : type [Exception ] | Iterable [type [Exception ]] | None = None ,
5962 ):
60- if errors is None :
61- errors = [Exception ]
62- elif not isinstance (errors , Iterable ):
63- errors = [errors ]
64-
65- self .errors = errors
63+ self .errors = (
64+ tuple (errors )
65+ if isinstance (errors , Iterable )
66+ else (errors ,)
67+ if errors
68+ else (Exception ,)
69+ )
6670 super ().__init__ (callback )
6771
68- async def check (self , client : hydrogram .Client , error : Exception ):
69- return any ( isinstance (error , e ) for e in self .errors )
72+ async def check (self , client : hydrogram .Client , update : Update , error : Exception ) -> bool :
73+ return isinstance (error , self .errors )
7074
71- def check_remove (self , error : Exception ):
72- return self . errors == error or any ( isinstance (error , e ) for e in self .errors )
75+ def check_remove (self , error : Exception ) -> bool :
76+ return isinstance (error , self .errors )
0 commit comments