return errors when websocket req fails

This commit is contained in:
Victor Shyba 2020-09-02 20:38:30 -03:00
parent 9b15799c72
commit 6bbfb45de7

View file

@ -152,12 +152,19 @@ class Daemon:
else:
params = msg.get('params', {})
method = getattr(self.api, msg['method'])
try:
result = await method(**params)
encoded_result = jsonrpc_dumps_pretty(result, service=self.service)
await web_socket.send_json({
'id': msg.get('id', ''),
'result': encoded_result
})
except Exception as e:
import traceback
traceback.print_exc()
log.exception("RPC error")
await web_socket.send_json({'id': msg.get('id', ''), 'result': "unexpected error: " + str(e)})
raise e
@staticmethod
async def on_shutdown(app):