New handle_exception plugin hook, refs #1770

Also refs:
- https://github.com/simonw/datasette-sentry/issues/1
- https://github.com/simonw/datasette-show-errors/issues/2
This commit is contained in:
Simon Willison 2022-07-17 16:24:39 -07:00
commit c09c53f345
10 changed files with 216 additions and 96 deletions

20
datasette/forbidden.py Normal file
View file

@ -0,0 +1,20 @@
from os import stat
from datasette import hookimpl, Response
@hookimpl(trylast=True)
def forbidden(datasette, request, message):
async def inner():
return Response.html(
await datasette.render_template(
"error.html",
{
"title": "Forbidden",
"error": message,
},
request=request,
),
status=403,
)
return inner