Skip to content

Commit

Permalink
fixup lua error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Nov 14, 2014
1 parent 51baab8 commit 59507f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/game_errors.hpp
Expand Up @@ -52,7 +52,7 @@ struct game_error : public error {
*/
struct lua_error : public error {
lua_error(const std::string& msg) : error("lua_error: " + msg) {}
lua_error(const std::string& msg, const std::string& context) : error(context + ": " + msg) {}
lua_error(const std::string& msg, const std::string& context) : error(context + ":\n " + msg) {}
};

/**
Expand Down
18 changes: 9 additions & 9 deletions src/scripting/lua_kernel_base.cpp
Expand Up @@ -487,15 +487,15 @@ bool lua_kernel_base::protected_call(int nArgs, int nRets, error_handler e_h)

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";
}

lua_pop(mState, 1);
Expand All @@ -517,13 +517,13 @@ bool lua_kernel_base::load_string(char const * prog, error_handler e_h)
std::string context = "When parsing a string to lua, ";

if (errcode == LUA_ERRSYNTAX) {
msg += " a syntax error: ";
context += " a syntax error";
} else if(errcode == LUA_ERRMEM){
msg += " a memory error: ";
context += " a memory error";
} else if(errcode == LUA_ERRGCMM) {
msg += " an error in garbage collection metamethod: ";
context += " an error in garbage collection metamethod";
} else {
msg += " an unknown error: ";
context += " an unknown error";
}

lua_pop(mState, 1);
Expand Down

0 comments on commit 59507f3

Please sign in to comment.