On Mon, Dec 1, 2008 at 9:18 AM, arpin <[EMAIL PROTECTED]> wrote: > John Labenski <[EMAIL PROTECTED]> writes: > >> >> if (m_wxlState.LuaPCall(1, 1) != 0) >> m_wxlState.wxlua_Error("Error in function... blah blah, get error >> string from stack..."); > > This code goes into no mans land. > > The original code reports the error on the console if the console is active > and in a message box if it is not active. I think it is the right solution.
The code above is basically identical to how it is now, what do you mean it goes into no man's land? To be sure; I agree that there is a currently a problem in that we really should check the return value of the pcall() and if there is an error, not try to get values from the stack and show an error message, but I do not want wxLua to crash. Take for example: modules/wxbind/src/wxadv_wxladv.cpp and the function wxLuaGridTableBase::GetNumberRows() ... m_wxlState.LuaPCall(1, 1); numrows = (int)m_wxlState.GetNumberType(-1); m_wxlState.lua_SetTop(nOldTop); If there is an error in the Lua code run by LuaPCall(), an error message string is left on the stack. The next line (see modues/wxlua/src/wxlstate.cpp); wxLuaState::GetNumberType(-1) calls wxlua_getnumbertype() which fails since the item at the top of the stack isn't a a number, wxlua_argerror() is called which calls wxlua_argerrormsg() which finally calls wxlua_error(). Regards, John ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users