mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Re-display user's query with an error message if an error occurs (#1346)
* Ignore _shape when returning errors
This commit is contained in:
parent
0f1e47287c
commit
9552414e1f
5 changed files with 44 additions and 13 deletions
|
|
@ -29,6 +29,7 @@ def convert_specific_columns_to_json(rows, columns, json_cols):
|
|||
def json_renderer(args, data, view_name):
|
||||
"""Render a response as JSON"""
|
||||
status_code = 200
|
||||
|
||||
# Handle the _json= parameter which may modify data["rows"]
|
||||
json_cols = []
|
||||
if "_json" in args:
|
||||
|
|
@ -44,6 +45,9 @@ def json_renderer(args, data, view_name):
|
|||
|
||||
# Deal with the _shape option
|
||||
shape = args.get("_shape", "arrays")
|
||||
# if there's an error, ignore the shape entirely
|
||||
if data.get("error"):
|
||||
shape = "arrays"
|
||||
|
||||
next_url = data.get("next_url")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue