[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Error source formatting
- From: Albert-Jan Brouwer <acj.brouwer@...>
- Date: Tue, 25 Nov 2003 17:02:46 +0100
Luiz Henrique de Figueiredo wrote:
> You can give your own name to a chunk. The "string" prefix is
> only added if you use the default name when loading the chunk.
> If you want it toappear like a file, use "@xxx", where "xxx" is
> the file name. If you want your own string, use "=xxx", and
> "xxx" will appear verbatim.
Cool, that does the trick.
> >So I guess what I'm asking for is a pluggable/customizable
> >means of formatting errors (...)
> The last argument in lua_pcall is there for this. Perhaps I'm
> missing something.
Unfortunately I have to run the Lua code through lua_resume()
which does not take an error handler function as argument.
> The core does not add a stack trace. If you don't want one,
> simply do not supply one when you call lua_pcall.
I do want a stack trace, and have been able to get one for most
errors by replacing luaL_where(). But that's going outside the
API. It would be much preferable if lua_resume() were to
sprout an extra optional errfunc argument. But then, that would
require passing the error function on every resume. As resumes
cannot be nested anyway, something that sets the errfunc field of
the Lua state once would do better.
Would something inspired by the lua_pcall implementation such
thread->errfunc = savestack(thread,luaA_index(thread,stackindex))
before the first resume work?