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/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:07d7aedb-e3a7-dac3-daeb-1bd4a69100c6 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8780:10046D:C56CB1D:FFC6FA3:6976B7ED |
| html-safe-nonce | c57c2d84deec4de5c21e38dca1395799ffae05cf7889c88ffde198c2b9168fe0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzgwOjEwMDQ2RDpDNTZDQjFEOkZGQzZGQTM6Njk3NkI3RUQiLCJ2aXNpdG9yX2lkIjoiOTA4OTQ5MDAxMzg1Nzk1Mzc3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd4b846f9fead463e08bf9653ecadad690c0e744d53e256031c7b620cedd1c6f |
| hovercard-subject-tag | pull_request:911329692 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/files |
| 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 | 032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5b577f6be6482e336e3c30e8daefa30144947b17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width