From b92cc434dbcc8f86407d5f6672b011bfd72f5a92 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 13 Dec 2023 23:04:09 +0000 Subject: [PATCH] core/run_command: be more robust in case of programming errors --- worldeditadditions_core/core/run_command.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worldeditadditions_core/core/run_command.lua b/worldeditadditions_core/core/run_command.lua index 6b4dff4..b0730af 100644 --- a/worldeditadditions_core/core/run_command.lua +++ b/worldeditadditions_core/core/run_command.lua @@ -37,9 +37,12 @@ local function run_command(cmdname, options, player_name, paramtext) end local parse_result = { options.parse(paramtext) } + if #parse_result >= 2 and parse_result[1] == false and type(parse_result[2]) ~= "string" then + minetest.log("warning", "[WorldEditAdditions:core] This is a bug. Parsing function for cmd "..cmdname.." failed but provided value of type "..type(parse_result[2]).." as an error message instead of the expected value of type string.All output from the parsing function: "..wea_c.inspect(parse_result)) + end local success = table.remove(parse_result, 1) if not success then - worldedit.player_notify(player_name, parse_result[1] or "Invalid usage (no further error message was provided by the command. This is probably a bug.)") + worldedit.player_notify(player_name, tostring(parse_result[1]) or "Invalid usage (no further error message was provided by the command. This is probably a bug.)") return false end