Enhancement - hooks

- Improved diagnostics of C++ side of the Lua API.
This commit is contained in:
Paul Beckingham 2010-01-19 22:19:40 -05:00
parent e3c28f3fb3
commit 8540cab0a6

View file

@ -491,10 +491,11 @@ bool API::callProgramHook (
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
// Call successful - get return values.
if (!lua_isnumber (L, -2)) throw std::string ("Error: '") + function + "' did not return a success indicator";
if (!lua_isnumber (L, -2))
throw std::string ("Error: '") + function + "' did not return a success indicator";
// TODO This doesn't seem to know that 'nil' was returned instead of a string.
// if (!lua_isstring (L, -1)) throw std::string ("Error: '") + function + "' did not return a message";
if (!lua_isstring (L, -1) && !lua_isnil (L, -1))
throw std::string ("Error: '") + function + "' did not return a message or nil";
int rc = lua_tointeger (L, -2);
const char* message = lua_tostring (L, -1);