From 7d9b627f372482e63c4cdb32c8fd9eb73fe54346 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 19 May 2023 19:47:33 +0000 Subject: [PATCH] Report attempts to call tfrpc methods that aren't registered. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4306 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/tfrpc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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]) {