mirror of
https://github.com/simonw/datasette.git
synced 2026-07-15 12:04:35 +02:00
Render error pages using datasette.render_template()
Avoids risk of important variables not being present.
This commit is contained in:
parent
a76646e3fd
commit
f3fa6ecf61
1 changed files with 5 additions and 9 deletions
|
|
@ -59,16 +59,12 @@ def handle_exception(datasette, request, exception):
|
|||
if request.path.split("?")[0].endswith(".json"):
|
||||
return Response.json(info, status=status, headers=headers)
|
||||
else:
|
||||
environment = datasette.get_jinja_environment(request)
|
||||
template = environment.select_template(templates)
|
||||
return Response.html(
|
||||
await template.render_async(
|
||||
dict(
|
||||
info,
|
||||
urls=datasette.urls,
|
||||
app_css_hash=datasette.app_css_hash(),
|
||||
menu_links=lambda: [],
|
||||
)
|
||||
await datasette.render_template(
|
||||
templates,
|
||||
info,
|
||||
request=request,
|
||||
view_name="error",
|
||||
),
|
||||
status=status,
|
||||
headers=headers,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue