2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

pc_rpc: report exception traceback

This commit is contained in:
Sebastien Bourdeauducq 2014-10-25 11:31:54 +08:00
parent a0ea83c98a
commit f106b238eb

View File

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