Skip to content

Commit

Permalink
lua: give more specific errors for "unknown modifiable property"
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Dec 30, 2014
1 parent a1a2e0e commit 1f124ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -342,7 +342,9 @@ static int impl_unit_set(lua_State *L)
modify_int_attrib("y", loc.y = value - 1; u.set_location(loc));
}

return luaL_argerror(L, 2, "unknown modifiable property");
std::string err_msg = "unknown modifiable property of unit: ";
err_msg += m;
return luaL_argerror(L, 2, err_msg.c_str());
}

/**
Expand Down Expand Up @@ -1256,7 +1258,10 @@ int game_lua_kernel::impl_game_config_set(lua_State *L)
modify_int_attrib("recall_cost", game_config::recall_cost = value);
modify_int_attrib("kill_experience", game_config::kill_experience = value);
modify_int_attrib("last_turn", tod_man().set_number_of_turns(value));
return luaL_argerror(L, 2, "unknown modifiable property");

std::string err_msg = "unknown modifiable property of game_config: ";
err_msg += m;
return luaL_argerror(L, 2, err_msg.c_str());
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/scripting/lua_team.cpp
Expand Up @@ -129,7 +129,9 @@ static int impl_side_set(lua_State *L)
return 0;
}

return luaL_argerror(L, 2, "unknown modifiable property");
std::string err_msg = "unknown modifiable property of side: ";
err_msg += m;
return luaL_argerror(L, 2, err_msg.c_str());
}

namespace lua_team {
Expand Down

0 comments on commit 1f124ff

Please sign in to comment.