From 33d5882a4af398b72e4d00c322094ad6879cae47 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 2 Feb 2015 15:36:13 -0700 Subject: [PATCH] Add traceback info when catching an exception to help with debugging. --- gns3server/web/route.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gns3server/web/route.py b/gns3server/web/route.py index b59acb4a..1aef6ed9 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -15,11 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys import json import jsonschema import asyncio import aiohttp import logging +import traceback log = logging.getLogger(__name__) @@ -110,9 +112,18 @@ class Route(object): response.set_status(e.status) response.json({"message": e.text, "status": e.status}) except VMError as e: + log.error("VM error detected: {type}".format(type=type(e)), exc_info=1) response = Response(route=route) response.set_status(500) response.json({"message": str(e), "status": 500}) + except Exception as e: + log.error("Uncaught exception detected: {type}".format(type=type(e)), exc_info=1) + response = Response(route=route) + response.set_status(500) + exc_type, exc_value, exc_tb = sys.exc_info() + lines = traceback.format_exception(exc_type, exc_value, exc_tb) + tb = "".join(lines) + response.json({"message": tb, "status": 500}) return response cls._routes.append((method, cls._path, control_schema))