Show more useful error message for SQL interrupted, closes #142

This commit is contained in:
Simon Willison 2018-05-28 14:24:19 -07:00
commit b0a95da963
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
3 changed files with 25 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import urllib.parse
from concurrent import futures
from pathlib import Path
from markupsafe import Markup
import pluggy
from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader
from sanic import Sanic, response
@ -461,6 +462,7 @@ class Datasette:
@app.exception(Exception)
def on_exception(request, exception):
title = None
help = None
if isinstance(exception, NotFound):
status = 404
info = {}
@ -473,6 +475,8 @@ class Datasette:
status = exception.status
info = exception.error_dict
message = exception.message
if exception.messagge_is_html:
message = Markup(message)
title = exception.title
else:
status = 500