Some minor improvements to Lua error messages

- Fix some missing whitespace in Lua log/error messages and add colons
- helper.lua: Improve error messages for config manipulators

It should now give the location of the misused helper call as the error
location, rather than the location where error was called within helper.lua
This commit is contained in:
Celtic Minstrel 2017-05-06 16:34:37 -04:00
parent 6a287f22c5
commit 71ae14e851
2 changed files with 8 additions and 8 deletions

View file

@ -41,9 +41,9 @@ local function ensure_config(cfg)
end
if type(cfg) == 'userdata' then
if getmetatable(cfg) == 'wml object' then return true end
error("Expected a table or wml object but got " .. getmetatable(cfg))
error("Expected a table or wml object but got " .. getmetatable(cfg), 3)
else
error("Expected a table or wml object but got " .. type(cfg))
error("Expected a table or wml object but got " .. type(cfg), 3)
end
return false
end

View file

@ -544,7 +544,7 @@ lua_kernel_base::~lua_kernel_base()
void lua_kernel_base::log_error(char const * msg, char const * context)
{
ERR_LUA << context << ": " << msg;
ERR_LUA << context << ": " << msg << '\n';
}
void lua_kernel_base::throw_exception(char const * msg, char const * context)
@ -578,15 +578,15 @@ bool lua_kernel_base::protected_call(lua_State * L, int nArgs, int nRets, error_
std::string context = "When executing, ";
if (errcode == LUA_ERRRUN) {
context += "Lua runtime error";
context += "Lua runtime error: ";
} else if (errcode == LUA_ERRERR) {
context += "Lua error in attached debugger";
context += "Lua error in attached debugger: ";
} else if (errcode == LUA_ERRMEM) {
context += "Lua out of memory error";
context += "Lua out of memory error: ";
} else if (errcode == LUA_ERRGCMM) {
context += "Lua error in garbage collection metamethod";
context += "Lua error in garbage collection metamethod: ";
} else {
context += "unknown lua error";
context += "unknown lua error: ";
}
context += msg ? msg : "null string";