[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: error handling
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 21 Dec 2012 10:18:45 -0200
> > I'm working a short time with Lua and primary with the C API, so I would like to know something about the error handling.
> > Does there anything exists like exception in Lua? Eg the Lua script calls a C/C++ function, on there C++ function an error
> > occurs and the C++ function throws an exception, I can catch the exception but I don't stop the program, but I would send
> > the error to the running Lua script, so the script can catch the error and deal with them.
> >
> > How can I handling errors on the Lua side?
>
> [...]
>
> In vanilla Lua, you'll want to explicitly catch the C++ exception and
> generate a call to lua_error.
Or better yet, call lua_error in the first place (instead of throwing
a C++ exception). In Lua, you can catch such errors with 'pcall'.
-- Roberto