Title: Errors handler by lrdcxdes · Pull Request #962 · pyrogram/pyrogram · GitHub
Open Graph Title: Errors handler by lrdcxdes · Pull Request #962 · pyrogram/pyrogram
X Title: Errors handler by lrdcxdes · Pull Request #962 · pyrogram/pyrogram
Description: from pyrogram import Client, filters app = Client(...) Use with decorator @app.on_error() # Global error handler, all other errors will be sent to it async def err_handler(_, e: Exception, update): print(e, 'handled') print(update) @app.on_error(ValueError) # Also you can use tuple with many exception classes, example: (ValueError, TypeError) async def custom_err_handler(_, e: ValueError, update): print(e, 'custom handled') print(update) Use without a decorator value_error_handler = ErrorHandler(custom_err_handler, ValueError) # Also you can use tuple with many exception classes, example: (ValueError, TypeError) global_error_handler = ErrorHandler(err_handler) # Global error handler, all other errors will be sent to it app.add_handler(value_error_handler) app.add_handler(global_error_handler) Startup example @app.on_message(filters.command('testerror')) async def msg_handler(_, m): raise Exception('TestError 123') @app.on_message(filters.command('valueerror')) async def custom_msg_handler(_, m): raise ValueError('TestError 123') app.run() Remove error handler app.remove_error_handler(value_error_handler) # Or you can use app.remove_error_handler(error=ValueError) # to remove all error handlers with ValueError in .errors # For remove global error handler, you can use: app.remove_error_handler()
Open Graph Description: from pyrogram import Client, filters app = Client(...) Use with decorator @app.on_error() # Global error handler, all other errors will be sent to it async def err_handler(_, e: Exception, update...
X Description: from pyrogram import Client, filters app = Client(...) Use with decorator @app.on_error() # Global error handler, all other errors will be sent to it async def err_handler(_, e: Exception, update...
Opengraph URL: https://github.com/pyrogram/pyrogram/pull/962
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:8200448f-1a0f-01ab-3ac4-24df8f9ebeac |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 8FC2:3C5710:8B629:B5ACD:697646E2 |
| html-safe-nonce | 29e777fb09fe380e8aaaaed172b72b0dad37e5a94a8fca16f2651b1ad9653ca6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkMyOjNDNTcxMDo4QjYyOTpCNUFDRDo2OTc2NDZFMiIsInZpc2l0b3JfaWQiOiI0MjM4OTAyNTgxMzkzNzcwMjEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | caaa76c2e0afa737abd912a14dfd6c02c5762214d42e758640323dc7f6758621 |
| hovercard-subject-tag | pull_request:911329692 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/pyrogram/pyrogram/pull/962/checks |
| twitter:image | https://avatars.githubusercontent.com/u/83734728?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/83734728?s=400&v=4 |
| og:image:alt | from pyrogram import Client, filters app = Client(...) Use with decorator @app.on_error() # Global error handler, all other errors will be sent to it async def err_handler(_, e: Exception, update... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6814b4cc7afd45cd6e64525d0cff0e76dd802f315a5b0e55a7abda1d1d070d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/pyrogram/pyrogram git https://github.com/pyrogram/pyrogram.git |
| octolytics-dimension-user_id | 34474300 |
| octolytics-dimension-user_login | pyrogram |
| octolytics-dimension-repository_id | 113971228 |
| octolytics-dimension-repository_nwo | pyrogram/pyrogram |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 113971228 |
| octolytics-dimension-repository_network_root_nwo | pyrogram/pyrogram |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ea235bfed58ef16c8a5642b3ac64b74f10c9f52 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width