mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-31 05:13:49 +02:00
Add traceback info when catching an exception to help with debugging.
This commit is contained in:
parent
471fbe576c
commit
33d5882a4a
@ -15,11 +15,13 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import logging
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -110,9 +112,18 @@ class Route(object):
|
|||||||
response.set_status(e.status)
|
response.set_status(e.status)
|
||||||
response.json({"message": e.text, "status": e.status})
|
response.json({"message": e.text, "status": e.status})
|
||||||
except VMError as e:
|
except VMError as e:
|
||||||
|
log.error("VM error detected: {type}".format(type=type(e)), exc_info=1)
|
||||||
response = Response(route=route)
|
response = Response(route=route)
|
||||||
response.set_status(500)
|
response.set_status(500)
|
||||||
response.json({"message": str(e), "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
|
return response
|
||||||
|
|
||||||
cls._routes.append((method, cls._path, control_schema))
|
cls._routes.append((method, cls._path, control_schema))
|
||||||
|
Loading…
Reference in New Issue
Block a user