More useful exception when unexpected output encountered from a kitten

This commit is contained in:
Kovid Goyal 2018-06-27 14:13:40 +05:30
parent d689c21283
commit 0c88e11cd7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -76,8 +76,11 @@ def launch(args):
def deserialize(output): def deserialize(output):
import json import json
if output.startswith('OK: '): if output.startswith('OK: '):
prefix, sz, rest = output.split(' ', 2) try:
return json.loads(rest[:int(sz)]) prefix, sz, rest = output.split(' ', 2)
return json.loads(rest[:int(sz)])
except Exception:
raise ValueError('Failed to parse kitten output: {!r}'.format(output))
def run_kitten(kitten, run_name='__main__'): def run_kitten(kitten, run_name='__main__'):