diff --git a/lbry/service/daemon.py b/lbry/service/daemon.py index a0a40bef8..b41b81543 100644 --- a/lbry/service/daemon.py +++ b/lbry/service/daemon.py @@ -152,12 +152,19 @@ class Daemon: else: params = msg.get('params', {}) method = getattr(self.api, msg['method']) - 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 - }) + 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):