diff --git a/core/tfrpc.js b/core/tfrpc.js index ac976c1e..f1bf48ec 100644 --- a/core/tfrpc.js +++ b/core/tfrpc.js @@ -39,9 +39,9 @@ function send(response) { function call_rpc(message) { if (message && message.message === 'tfrpc') { - let method = g_api[message.method]; let id = message.id; if (message.method) { + let method = g_api[message.method]; if (method) { try { Promise.resolve(method(...message.params)).then(function(result) { @@ -53,7 +53,7 @@ function call_rpc(message) { send({message: 'tfrpc', id: id, error: error}); } } else { - throw new Error(message.method + ' not found.'); + send({message: 'tfrpc', id: id, error: `Method '${message.method}' not found.`}); } } else if (message.error !== undefined) { if (g_calls[id]) {