Show exception instead of just "500 Internal Server Error" in the API server's reply
Do some illegal command like this:
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"rpcs": [{"query": { "model": "dataset", "filters": [ {"op": "gt", "name": "duration", "value": 60} ] } }]}' \
$MARV_API/v1/rpcs
This command outputs:
500 Internal Server Error
Server got itself in trouble
The HTTP server prints:
[2020-09-10 18:09:32 +0000] [8] [ERROR] Error handling request
Traceback (most recent call last):
File "/opt/marv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/opt/marv/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/opt/marv/lib/python3.7/site-packages/marv_webapi/tooling.py", line 95, in __call__
return await func(request)
File "/opt/marv/lib/python3.7/site-packages/marv_webapi/rpcs.py", line 54, in rpc_entry
order, limit, offset)
File "/opt/marv/lib/python3.7/site-packages/marv/db.py", line 79, in wrapper
return await func(database, *args, transaction=transaction, **kwargs)
File "/opt/marv/lib/python3.7/site-packages/marv/db.py", line 1121, in rpc_query
query = query.where(resolve_filter(table, filt))
File "/opt/marv/lib/python3.7/site-packages/marv/db.py", line 251, in resolve_filter
raise FilterError(f'Field {name!r} not on model {tablemeta.table}')
marv.db.FilterError: Field 'duration' not on model dataset
Maybe it would be better to also send the exception to the client to give some background of what went wrong? In my case it would be very useful to know that the duration field is invalid