diff --git a/src/API.cpp b/src/API.cpp index fa10f321e..566692710 100644 --- a/src/API.cpp +++ b/src/API.cpp @@ -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);