From 5f65385207b87a823c940042de3b494d69da9960 Mon Sep 17 00:00:00 2001 From: Dmitry Kokorin Date: Wed, 30 Jun 2021 19:00:57 +0300 Subject: [PATCH] [WIP] Python: rest_api error handling is removed, comments are added --- python/rest-api/rest_api.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/python/rest-api/rest_api.py b/python/rest-api/rest_api.py index 68e3407..d798626 100644 --- a/python/rest-api/rest_api.py +++ b/python/rest-api/rest_api.py @@ -53,6 +53,7 @@ class MethodRegistry: if payload: payload = json.loads(payload) + #It would be essential to validate JSON schema here f_result = f(f_self, payload) @@ -72,16 +73,9 @@ class RestAPI: def _process_request(self, method, url, payload): methods = self.registry.methods[method] - if url in methods.keys(): -# try: -# return methods[url](self, payload) -# except json.JSONDecodeError: -# return 'Bad request' -# finally: -# return 'Internal server error' -# else: -# return 'Not found' + #It would be natural to handle exceptions here + if url in methods.keys(): return methods[url](self, payload) def get(self, url, payload=None):