lua-users home
lua-l archive

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


Hmmm, on a related note to this (but not the same), I'd like to 'throw' an
error from a c function called from lua, that will include the line number
that lua was executing that called the c function.

Is this possible?

----- Original Message ----- 
From: "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Tuesday, August 17, 2004 8:01 PM
Subject: Re: Finding line number of script abort


> > When a script aborts, how can I identify the chunk and the line number?
>
> If you mean a Lua script that dies because of an error, then the info you
want
> is part of the error message left on the top of the stack, assuming you
run
> Lua in protected mode, that is with a call to lua_cpcall. Otherwise, the
> error message is made but lost because the Lua core panics. You may set a
> panic function with lua_atpanic; you can't get the error message, but at
least
> you'll be able to call abort() and load a debugger and see where you were.
> --lhf
>