Enhancement - hooks
- Improved diagnostics of C++ side of the Lua API.
This commit is contained in:
@@ -491,10 +491,11 @@ bool API::callProgramHook (
|
|||||||
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
|
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
|
||||||
|
|
||||||
// Call successful - get return values.
|
// 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) && !lua_isnil (L, -1))
|
||||||
// if (!lua_isstring (L, -1)) throw std::string ("Error: '") + function + "' did not return a message";
|
throw std::string ("Error: '") + function + "' did not return a message or nil";
|
||||||
|
|
||||||
int rc = lua_tointeger (L, -2);
|
int rc = lua_tointeger (L, -2);
|
||||||
const char* message = lua_tostring (L, -1);
|
const char* message = lua_tostring (L, -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user