From f106b238eb46394f7a31239c34bbf23bd607a0f5 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 25 Oct 2014 11:31:54 +0800 Subject: [PATCH] pc_rpc: report exception traceback --- artiq/management/pc_rpc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/artiq/management/pc_rpc.py b/artiq/management/pc_rpc.py index 3035f0956..43681622a 100644 --- a/artiq/management/pc_rpc.py +++ b/artiq/management/pc_rpc.py @@ -1,6 +1,7 @@ import socket import json import asyncio +import traceback class RemoteError(Exception): @@ -29,7 +30,7 @@ class Client: if obj["result"] == "ok": return obj["ret"] elif obj["result"] == "error": - raise RemoteError(obj["message"]) + raise RemoteError(obj["message"] + "\n" + obj["traceback"]) else: raise ValueError @@ -81,8 +82,9 @@ class Server: obj = {"result": "ok", "ret": ret} except Exception as e: obj = {"result": "error", - "message": type(e).__name__ + ": " + str(e)} - line = json.dumps(obj) + "\n" + "message": type(e).__name__ + ": " + str(e), + "traceback": traceback.format_exc()} + line = pyon.encode(obj) + "\n" writer.write(line.encode()) finally: writer.close()