aboutsummaryrefslogtreecommitdiff
path: root/zenserver/config.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-22 19:20:58 +0200
committerStefan Boberg <[email protected]>2021-09-22 19:20:58 +0200
commitc1b11c07d6c8c21d6a76e3da461d84e4bf19cfc8 (patch)
tree105e315c61605d546296e0ab00967d87783fc573 /zenserver/config.cpp
parentMade icon resource path relative, as it should be (diff)
downloadzen-c1b11c07d6c8c21d6a76e3da461d84e4bf19cfc8.tar.xz
zen-c1b11c07d6c8c21d6a76e3da461d84e4bf19cfc8.zip
Improved error message when lua config file parsing fails.
Now includes line number and other details about what lua does not like
Diffstat (limited to 'zenserver/config.cpp')
-rw-r--r--zenserver/config.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index 1a24bba0d..c21638258 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -277,22 +277,24 @@ ParseServiceConfig(const std::filesystem::path& DataRoot, ZenServiceConfig& Serv
try
{
- sol::load_result config = lua.load(std::string_view((const char*)LuaScript.Data(), LuaScript.Size()), "zencfg");
+ sol::load_result config = lua.load(std::string_view((const char*)LuaScript.Data(), LuaScript.Size()), "zen_cfg");
- if (config.status() != sol::load_status::ok)
+ if (!config.valid())
{
+ sol::error err = config;
+
std::string ErrorString = sol::to_string(config.status());
- throw std::runtime_error("lua '{}' error"_format(ErrorString));
+ throw std::runtime_error("{} error: {}"_format(ErrorString, err.what()));
}
config();
}
catch (std::exception& e)
{
- ZEN_ERROR("config script failure: {}", e.what());
+ ZEN_ERROR("config failure: {}", e.what());
- throw std::runtime_error("fatal zen global config script ({}) failure: {}"_format(ConfigScript, e.what()).c_str());
+ throw std::runtime_error("failed to run global config script ('{}'): {}"_format(ConfigScript, e.what()).c_str());
}
ServiceConfig.MeshEnabled = lua["mesh"]["enable"].get_or(ServiceConfig.MeshEnabled);