@@ -232,10 +232,9 @@ async def _process_packet(self, packet, lock):
232232
233233 async def _handle_update (self , handler , handler_type , parsed_update , update , users , chats ):
234234 try :
235- if isinstance (handler , handler_type ) and await handler .check (
236- self .client , parsed_update
237- ):
238- await self ._execute_callback (handler , parsed_update )
235+ if isinstance (handler , handler_type ):
236+ if await handler .check (self .client , parsed_update ):
237+ await self ._execute_callback (handler , parsed_update )
239238 elif isinstance (handler , RawUpdateHandler ):
240239 await self ._execute_callback (handler , update , users , chats )
241240 except (hydrogram .StopPropagation , hydrogram .ContinuePropagation ) as e :
@@ -249,17 +248,17 @@ async def _handle_exception(self, parsed_update, exception):
249248 for error_handler in self .error_handlers :
250249 try :
251250 if await error_handler .check (self .client , parsed_update , exception ):
252- await error_handler .callback (self .client , parsed_update , exception )
253251 handled_error = True
254252 break
255253 except hydrogram .StopPropagation :
256254 raise
257- except (hydrogram .ContinuePropagation , Exception ) as inner_exception :
258- if isinstance (inner_exception , Exception ):
259- log .exception (inner_exception )
255+ except hydrogram .ContinuePropagation :
256+ continue
257+ except Exception as inner_exception :
258+ log .exception ("Error in error handler: %s" , inner_exception )
260259
261260 if not handled_error :
262- log .exception (exception )
261+ log .exception ("Unhandled exception: %s" , exception )
263262
264263 async def _execute_callback (self , handler , * args ):
265264 if inspect .iscoroutinefunction (handler .callback ):
0 commit comments