From 5bec49f7a021908339bea20ea38fa6b9bf9fe984 Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:49:28 -0500 Subject: [PATCH] Suspects: Fix loginserver error handling --- server/chat-plugins/suspect-tests.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/chat-plugins/suspect-tests.ts b/server/chat-plugins/suspect-tests.ts index de8bc5c870..53bfe8fe37 100644 --- a/server/chat-plugins/suspect-tests.ts +++ b/server/chat-plugins/suspect-tests.ts @@ -100,12 +100,14 @@ export const commands: Chat.ChatCommands = { reqData[k] = val; } - const [, error] = await LoginServer.request("suspects/add", { + const [out, error] = await LoginServer.request("suspects/add", { format: format.id, reqs: JSON.stringify(reqData), url: urlActual, }); - if (error) throw new Chat.ErrorMessage("Error adding suspect test: " + error.message); + if (out?.actionerror || error) { + throw new Chat.ErrorMessage("Error adding suspect test: " + (out?.actionerror || error.message)); + } this.privateGlobalModAction(`${user.name} ${suspectTests.suspects[format.id] ? "edited the" : "added a"} ${format.name} suspect test.`); this.globalModlog('SUSPECTTEST', null, `${suspectTests.suspects[format.id] ? "edited" : "added"} ${format.name}`); @@ -130,10 +132,12 @@ export const commands: Chat.ChatCommands = { const test = suspectTests.suspects[format]; if (!test) return this.errorReply(`There is no suspect test for '${target}'. Check spelling?`); - const [, error] = await LoginServer.request('suspects/end', { + const [out, error] = await LoginServer.request('suspects/end', { format, }); - if (error) throw new Chat.ErrorMessage(`Error ending suspect: ${error.message}`); + if (out?.actionerror || error) { + throw new Chat.ErrorMessage(`Error ending suspect: ${out?.actionerror || error?.message}`); + } this.privateGlobalModAction(`${user.name} removed the ${test.tier} suspect test.`); this.globalModlog('SUSPECTTEST', null, `removed ${test.tier}`);