1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Return proper JSON error when something goes wrong on any endpoint

This commit is contained in:
Julien Duponchelle 2016-07-20 17:17:42 +02:00
parent f68c1f0bde
commit ff4fc5eb8b
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 8 additions and 9 deletions

View File

@ -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"))):

View File

@ -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")