forked from M-Labs/artiq
1
0
Fork 0

protocols/pyon: improve error reporting of non-serializable type

This commit is contained in:
Sebastien Bourdeauducq 2015-10-29 09:42:45 +08:00
parent 32c95f24d0
commit f0eed1182a
1 changed files with 4 additions and 1 deletions

View File

@ -132,7 +132,10 @@ class _Encoder:
return r
def encode(self, x):
return getattr(self, "encode_" + _encode_map[type(x)])(x)
ty = _encode_map.get(type(x), None)
if ty is None:
raise TypeError(repr(x) + " is not PYON serializable")
return getattr(self, "encode_" + ty)(x)
def encode(x, pretty=False):