forked from M-Labs/artiq
pc_rpc: report exception traceback
This commit is contained in:
parent
a0ea83c98a
commit
f106b238eb
|
@ -1,6 +1,7 @@
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
class RemoteError(Exception):
|
class RemoteError(Exception):
|
||||||
|
@ -29,7 +30,7 @@ class Client:
|
||||||
if obj["result"] == "ok":
|
if obj["result"] == "ok":
|
||||||
return obj["ret"]
|
return obj["ret"]
|
||||||
elif obj["result"] == "error":
|
elif obj["result"] == "error":
|
||||||
raise RemoteError(obj["message"])
|
raise RemoteError(obj["message"] + "\n" + obj["traceback"])
|
||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
@ -81,8 +82,9 @@ class Server:
|
||||||
obj = {"result": "ok", "ret": ret}
|
obj = {"result": "ok", "ret": ret}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
obj = {"result": "error",
|
obj = {"result": "error",
|
||||||
"message": type(e).__name__ + ": " + str(e)}
|
"message": type(e).__name__ + ": " + str(e),
|
||||||
line = json.dumps(obj) + "\n"
|
"traceback": traceback.format_exc()}
|
||||||
|
line = pyon.encode(obj) + "\n"
|
||||||
writer.write(line.encode())
|
writer.write(line.encode())
|
||||||
finally:
|
finally:
|
||||||
writer.close()
|
writer.close()
|
||||||
|
|
Loading…
Reference in New Issue