Re: error exceptions
liam mail <[email protected]> Tue, 9 Aug 2011 18:01:27 +0100
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <CAOMMs2TfZPnrHcNg7Ax-p-SSVS4-xgUXregXwakwewrjV_jgpg@mail.gmail.com> |
On 9 August 2011 15:43, Willi Schinmeyer <[email protected]> wrote: > Am Dienstag, den 09.08.2011, 07:17 -0700 schrieb Josh Stratton: > > so I'm assuming there is some error in there > > I thought should raise an exception. > > Nope, errors don't usually raise exceptions, they just change the return > value. Read the manual regarding luaL_dostring(), I don't know how to > check its success off the top of my head. > > > > ------------------------------------------------------------------------------ > uberSVN's rich system and user administration capabilities and model > configuration take the hassle out of deploying and managing Subversion and > the tools developers use with it. Learn more about uberSVN and get a free > download at: http://p.sf.net/sfu/wandisco-dev2dev > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user > luaL_dostring [1] is really a macro which calls two functions in Lua 5.1, it simply calls luaL_loadstring [2] then lua_pcall [3] if there was not an error. The macro is an "logical or" of both function return values and therefore luaL_dostring as such "returns" a result, either it is 0 for success or 1 for error. Using luaL_dostring looses information of the error category in the form of a int which is returned by either of the function yet the function which errors also puts a message on the top of the stack. You therefore can check the return value of luaL_dostring and get the error from the top of the stack but I always advise that people should at least call these two functions yourself or use a function which replaces luaL_dostring functionality, from there you can throw a typed none generic exception using the int return value from the failing function if you wish [4] :) [1] http://www.lua.org/manual/5.1/manual.html#luaL_dostring [2] http://www.lua.org/manual/5.1/manual.html#luaL_loadstring [3] http://www.lua.org/manual/5.1/manual.html#lua_pcall [4] http://code.google.com/p/oolua/source/browse/trunk/src/oolua_check_result.cpp Liam ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user