error managment in LUA 5.0

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

error managment in LUA 5.0

doneval
Hi all,

I'm porting my code from 4.2 to 5.0 and I can't understand the new 
error managment. Could anyone explain it? in the documentation it's 
not very clear:

- Where is the error message I send with "lua_error()"? 
- Where I can get it after the error? maybe in "lua_atpanic()"?

Thanks you all!
Ricard


Reply | Threaded
Open this post in threaded view
|

Re: error managment in LUA 5.0

paul winwood-3
Hi,

> - Where is the error message I send with "lua_error()"? 

You call lua_error with your own error when your code that is called 
by lua detects an error of some sort.

> - Where I can get it after the error? maybe in "lua_atpanic()"?

The way I see it the routine called by lua_atpanic is used as a last 
resort. If you use lua_pcall() or similar or have your own functions 
that load Lua code then you get the error message at the top 
of the stack and a error return code when a error occurs (including 
lua_error being called). There of examples of this in the auxlib I 
think.

This is another reason (IMHO) that Lua 5.0 is much cleaner in its 
interface than Lua 4.0.

Cheers,
Paul.