Return 500 when an exception is thrown, never try to .encode None
This commit is contained in:
parent
b0c27eff0b
commit
c3ace4be2e
1 changed files with 9 additions and 5 deletions
|
@ -27,12 +27,16 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||||
code = 401
|
code = 401
|
||||||
else:
|
else:
|
||||||
if path.startswith("/api/"):
|
if path.startswith("/api/"):
|
||||||
response = _events.on("api").on(method).on(endpoint
|
try:
|
||||||
).call_for_result(params=params, path=args, data=data)
|
event_response = _events.on("api").on(method).on(
|
||||||
|
endpoint).call_unsafe_for_result(
|
||||||
|
params=params, path=args, data=data)
|
||||||
|
except:
|
||||||
|
code = 500
|
||||||
|
|
||||||
if response:
|
if event_response:
|
||||||
response = json.dumps(response, sort_keys=True,
|
response = json.dumps(event_response,
|
||||||
indent=4)
|
sort_keys=True, indent=4)
|
||||||
code = 200
|
code = 200
|
||||||
|
|
||||||
self.send_response(code)
|
self.send_response(code)
|
||||||
|
|
Loading…
Reference in a new issue