From 8801bbd2f3d1339f5a5ecad48e8f51f68b146604 Mon Sep 17 00:00:00 2001 From: leonoverweel Date: Mon, 3 Apr 2017 09:55:18 +0200 Subject: Fix error handling in HTTP requests Now return the proper status code instead of 500 --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 41799dae..ec404239 100644 --- a/main.py +++ b/main.py @@ -168,7 +168,7 @@ def _process_message(message): response = request.process() return (request, response) - + except exceptions.AuthorizationTokenError as e: response = rest.Response(401, 'Authorization error') response.id = message['id'] @@ -188,6 +188,10 @@ def _process_message(message): response.id = message['id'] traceback.print_exc() - return ({'method': message['method'], 'path': message['path']}, response) + request = rest.Request() + request.method = message['method'] + request.path = message['path'] + + return (request, response) SOCKET_IO_CORE.run(FLASK_CORE_APP, host='0.0.0.0', port=8081) -- cgit v1.2.3