From 29a198bfcedeb5d22e0d34c5c53098142acdf477 Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 22 Apr 2025 14:07:46 +0200 Subject: [PATCH] Display more info when error parsing config.lua value --- system/functions.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/system/functions.php b/system/functions.php index de038e5a..acacd30e 100644 --- a/system/functions.php +++ b/system/functions.php @@ -972,12 +972,19 @@ function load_config_lua($filename) } else { - foreach($result as $tmp_key => $tmp_value) // load values definied by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull + foreach($result as $tmp_key => $tmp_value) { // load values defined by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull $value = str_replace($tmp_key, $tmp_value, $value); - $ret = @eval("return $value;"); - if((string) $ret == '' && trim($value) !== '""') // = parser error - { - throw new RuntimeException('ERROR: Loading config.lua file. Line ' . ($ln + 1) . ' of LUA config file is not valid [key: ' . $key . ']'); + } + + try { + $ret = eval("return $value;"); + } + catch (Throwable $e) { + throw new RuntimeException('ERROR: Loading config.lua file. Line: ' . ($ln + 1) . ' - Unable to parse value "' . $value . '" - ' . $e->getMessage()); + } + + if((string) $ret == '' && trim($value) !== '""') { + throw new RuntimeException('ERROR: Loading config.lua file. Line ' . ($ln + 1) . ' is not valid [key: ' . $key . ']'); } $result[$key] = $ret; }