-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle_exception
plugin hook for custom error handling
#1770
Comments
I think the hook gets called any time any exception makes it to this function: Lines 1374 to 1440 in 950cc76
Multiple plugins can register for the hook. If they return a I think Datasette should have a default plugin hook implementation which returns the 500 error page. |
Proposed hook design: @hookspec
def handle_exception(datasette, request, exception):
"""Handle an uncaught exception""" It takes |
... maybe it should take |
It's weird to return a |
Returning a |
Design decision: @hookspec
def handle_exception(datasette, request, exception):
"""Handle an uncaught exception. Can return a Response or None.""" It will also support returning an awaitable, using the |
I'll implement this hook and then release it as |
In |
Had to lookup that datasette/datasette/utils/asgi.py Lines 16 to 29 in 950cc76
|
handle_exception
plugin hook for custom error handling
I need to refactor this code so that Reason is that those already have a plugin hook of their own: Lines 1384 to 1395 in 8188f55
My first attempt at this refactored that entire |
I think this is the right place to move the code to catch Lines 1269 to 1278 in 8188f55
|
Keeping this issue open until I've proven the new plugin hook works by releasing a plugin that uses it. |
Documentation for the new hook: https://docs.datasette.io/en/latest/plugin_hooks.html#handle-exception-datasette-request-exception |
I've tested this with |
I need this for a couple of plugins, both of which are broken at the moment:
The text was updated successfully, but these errors were encountered: