[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How do I get the filename and line number from a failed luaL_loadfile?
- From: Ben Kelly <ranavin@...>
- Date: Thu, 21 Aug 2008 20:22:42 -0400
E. Wing wrote:
> Thanks for the clarification. For lua_pcall, I've been providing my
> own error function that does a stack trace and saves the line number
> and file name. In the case of require(), this function wasn't being
> called so I assumed it was due to the luaL_loadfile. But it turns out
> that my error function doesn't get invoked in this case.
>
That strikes me as odd; pcall should catch any function thrown from
inside the state, whether from the top level or from anything it calls,
including require() itself and require()'d files.
> I realized I needed a separate Lua state anyway because it's not clear
> to me if the string library is loaded in my other state and if so, if
> a script didn't remove the 'string' table.
>
You can always save the string.* functions you need in the LUA_REGISTRY.
That guarantees they'll be around when you need them (provided you
aren't given guest scripts the ability to load binary modules or call
the debug library).
Ben Kelly