From 7f2f70e1a60d2a89bded7b7ac93ab607efce286d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Wed, 3 Jun 2015 17:03:49 +0200 Subject: [PATCH] Change signalcall to protectedcall in console Even though they kind of do the same (calling function in protected mode), @edubart suggested to use a different function for the sake of readability. --- modules/corelib/util.lua | 10 ++++++++++ modules/game_console/console.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/corelib/util.lua b/modules/corelib/util.lua index 0691fc88..157c28b0 100644 --- a/modules/corelib/util.lua +++ b/modules/corelib/util.lua @@ -296,6 +296,16 @@ function numbertoboolean(number) end end +function protectedcall(func, ...) + local status, ret = pcall(func, ...) + if status then + return ret + end + + perror(ret) + return false +end + function signalcall(param, ...) if type(param) == 'function' then local status, ret = pcall(param, ...) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index d33f8b47..74e51249 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -694,7 +694,7 @@ function processChannelTabMenu(tab, mousePos, mouseButton) table.insert(lines, 1, os.date('\nChannel saved at %a %b %d %H:%M:%S %Y')) if g_resources.fileExists(filepath) then - table.insert(lines, 1, signalcall(g_resources.readFileContents, filepath) or '') + table.insert(lines, 1, protectedcall(g_resources.readFileContents, filepath) or '') end g_resources.writeFileContents(filepath, table.concat(lines, '\n'))