mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Show SQL query when reporting time limit error, closes #1819
This commit is contained in:
parent
212137a90b
commit
5f9f567acb
4 changed files with 35 additions and 13 deletions
|
|
@ -476,7 +476,10 @@ class WriteTask:
|
|||
|
||||
|
||||
class QueryInterrupted(Exception):
|
||||
pass
|
||||
def __init__(self, e, sql, params):
|
||||
self.e = e
|
||||
self.sql = sql
|
||||
self.params = params
|
||||
|
||||
|
||||
class MultipleValues(Exception):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import asyncio
|
||||
import csv
|
||||
import hashlib
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
import time
|
||||
import urllib
|
||||
from markupsafe import escape
|
||||
|
||||
|
||||
import pint
|
||||
|
||||
|
|
@ -24,11 +26,9 @@ from datasette.utils import (
|
|||
path_with_removed_args,
|
||||
path_with_format,
|
||||
sqlite3,
|
||||
HASH_LENGTH,
|
||||
)
|
||||
from datasette.utils.asgi import (
|
||||
AsgiStream,
|
||||
Forbidden,
|
||||
NotFound,
|
||||
Response,
|
||||
BadRequest,
|
||||
|
|
@ -371,13 +371,18 @@ class DataView(BaseView):
|
|||
) = response_or_template_contexts
|
||||
else:
|
||||
data, extra_template_data, templates = response_or_template_contexts
|
||||
except QueryInterrupted:
|
||||
except QueryInterrupted as ex:
|
||||
raise DatasetteError(
|
||||
"""
|
||||
SQL query took too long. The time limit is controlled by the
|
||||
textwrap.dedent(
|
||||
"""
|
||||
<p>SQL query took too long. The time limit is controlled by the
|
||||
<a href="https://docs.datasette.io/en/stable/settings.html#sql-time-limit-ms">sql_time_limit_ms</a>
|
||||
configuration option.
|
||||
""",
|
||||
configuration option.</p>
|
||||
<pre>{}</pre>
|
||||
""".format(
|
||||
escape(ex.sql)
|
||||
)
|
||||
).strip(),
|
||||
title="SQL Interrupted",
|
||||
status=400,
|
||||
message_is_html=True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue