From ff4fc5eb8b2dccf48fcb128ef1c5a49f87fab7d3 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 20 Jul 2016 17:17:42 +0200 Subject: [PATCH] Return proper JSON error when something goes wrong on any endpoint --- .../handlers/api/controller/project_handler.py | 1 - gns3server/web/route.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gns3server/handlers/api/controller/project_handler.py b/gns3server/handlers/api/controller/project_handler.py index c6baf615..07ddad03 100644 --- a/gns3server/handlers/api/controller/project_handler.py +++ b/gns3server/handlers/api/controller/project_handler.py @@ -231,7 +231,6 @@ class ProjectHandler: controller = Controller.instance() project = controller.get_project(request.match_info["project_id"]) - started = False for data in project.export(include_images=bool(request.GET.get("include_images", "0"))): diff --git a/gns3server/web/route.py b/gns3server/web/route.py index 22bad4c0..2e30acf2 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -161,15 +161,15 @@ class Route(object): if response: return response - # Non API call - if api_version is None or raw is True: - response = Response(request=request, route=route, output_schema=output_schema) - - yield from func(request, response) - return response - - # API call try: + # Non API call + if api_version is None or raw is True: + response = Response(request=request, route=route, output_schema=output_schema) + + yield from func(request, response) + return response + + # API call if "controller" in func.__module__ and server_config.getboolean("controller", False) is False: raise aiohttp.web.HTTPForbidden(text="The server is not a controller")