Add filters and class based handler for errors

This commit is contained in:
Alex Root Junior 2020-04-12 23:20:44 +03:00
parent 9e673998f0
commit 0fbd2819f9
9 changed files with 167 additions and 1 deletions

View file

@ -0,0 +1,29 @@
# ErrorHandler
There is base class for error handlers.
## Simple usage:
```pyhton3
from aiogram.handlers import ErrorHandler
...
@router.errors_handler()
class MyHandler(ErrorHandler):
async def handle(self) -> Any:
log.exception(
"Cause unexpected exception %s: %s",
self.event.__class__.__name__,
self.event
)
```
## Extension
This base handler is subclass of [BaseHandler](basics.md#basehandler)
## Related pages
- [BaseHandler](basics.md#basehandler)
- [Router.errors_handler](../router.md#errors)
- [Filters](../filters/exception.md)