mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix for weird nested exception in RequestTimeout
I saw this error:
sanic.exceptions.RequestTimeout: Request Timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/simonw/Dropbox/Development/datasette/venv/lib/python3.6/site-packages/sanic/handlers.py", line 82, in response
response = handler(request=request, exception=exception)
File "/Users/simonw/Dropbox/Development/datasette/datasette/app.py", line 512, in on_exception
if request.path.split("?")[0].endswith(".json"):
AttributeError: 'NoneType' object has no attribute 'path'
Strangely "if request and request.path..." did not work here, because the
Sanic Request class extends builtins.dict and hence evaluates to False if it
has no headers.
This commit is contained in:
parent
24af1004a4
commit
d08faa8987
1 changed files with 1 additions and 1 deletions
|
|
@ -509,7 +509,7 @@ class Datasette:
|
|||
info.update(
|
||||
{"ok": False, "error": message, "status": status, "title": title}
|
||||
)
|
||||
if request.path.split("?")[0].endswith(".json"):
|
||||
if request is not None and request.path.split("?")[0].endswith(".json"):
|
||||
return response.json(info, status=status)
|
||||
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue