when a post handler fails, log the traceback to the console

https://forums.ankiweb.net/t/cant-change-note-type/14809
This commit is contained in:
Damien Elmes 2021-11-12 11:54:13 +10:00
parent 610ef8f043
commit 7a6acc83a5

View file

@ -485,11 +485,15 @@ def _extract_collection_post_request(path: str) -> DynamicRequest | NotFound:
if handler := post_handlers.get(path):
# convert bytes/None into response
def wrapped() -> Response:
try:
if data := handler():
response = flask.make_response(data)
response.headers["Content-Type"] = "application/binary"
else:
response = flask.make_response("", HTTPStatus.NO_CONTENT)
except:
print(traceback.format_exc())
response = flask.make_response("", HTTPStatus.INTERNAL_SERVER_ERROR)
return response
return wrapped