ErrorHandler

class pyrogram.handlers.ErrorHandler

Bases: Handler

The Error handler class. Used to handle errors. It is intended to be used with add_handler()

For a nicer way to register this handler, have a look at the on_error() decorator.

Parameters:
  • callback (Callable) – Pass a function that will be called when a new Error arrives. It takes (client, error) as positional arguments (look at the section below for a detailed description).

  • exceptions (Exception | Iterable of Exception, optional) – Pass one or more exception classes to allow only a subset of errors to be passed in your callback function.

Other Parameters:
  • client (Client) – The Client itself, useful when you want to call other API methods inside the error handler.

  • update (Update) – The update that caused the error.

  • error (Exception) – The error that was raised.

async check(client, update, exception)

Check whether this handler should process the given update.

check_remove(error)

Check and conditionally remove this error handler.