lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Le 19 Sep 2006 à 10:42, jason bright a écrit :

On 9/19/06, Robert Raschke <> wrote: Jasmin Patry wrote:
> I'm wondering if anybody has had any experience modifying how Lua
> handles errors in scripts.

I just use pcall() for that kind of thing.


Not to hijack this thread, but can somebody point to any wiki articles or otherwise about using error handlers with lua_pcall(). Doing my first project with Lua and everything is going swimmingly, but would like some more robustness and feedback to the user ( e.g. reporting the actual line and some context for a syntax error). How lua_pcall uses it's error handler isn't very clear to me from PiL nor the online docs.

Have a look at the source code for the supplied interpreter in lua.c, it uses a lua_pcall error handler to produce stack back-traces when there is an error.