diff options
| author | Stefan Boberg <[email protected]> | 2021-09-22 19:20:58 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-22 19:20:58 +0200 |
| commit | c1b11c07d6c8c21d6a76e3da461d84e4bf19cfc8 (patch) | |
| tree | 105e315c61605d546296e0ab00967d87783fc573 /zenserver/config.cpp | |
| parent | Made icon resource path relative, as it should be (diff) | |
| download | zen-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.cpp | 12 |
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); |