On Tue, Mar 24, 2009 at 7:57 PM, Brian McCallister <bri...@skife.org> wrote: > On Sat, Mar 21, 2009 at 10:54 AM, Bertrand Mansion <bmans...@mamasam.net> > wrote: >> In order to be able to detect if a lua file fails to compile and get >> an informative error message like : >> Error! >> /web/localhost/htdocs/info.lua:174: '=' expected near '+' >> instead of : >> Error! >> attempt to call a nil value >> >> I suggest you move the load/pcall function from >> lua_vmprep:apl_get_lua_state() to mod_lua:lua_handler() and >> mod_lua:lua_request_rec_hook_harness() like in the attached patch. > > I disagree with this change, but agree with the intention. We need a > good way to get compilation errors back to folks asking for the > lua_State. We could use a state flag in the vm create callback which > says what happened -- instead of just calling it with a valid > lua_State when it is created, it will be called every time, with an > enumeration of what happened, one of { create, reuse, syntax_error, > other_error } or such. > > I think the lua_State may hold the compilation problems, but am not > sure, need to go poke around -- I won't have a chance for a while > still, am dealing with a family medical issue for a couple weeks > (nothing urgent, just needing attention).
Peter's suggestion is ok for me. I just need to figure out how to do that :) >> I haven't yet tested how my patch works with hooks but it seems to be >> ok for lua_handler. I am not sure about the lua_gc() in case pcall >> fails, it just seem logical and that's how it's done in Lua's lua.c >> interpreter. >> >> PS: I wish mod_lua was under a distributed SCM like Git or Mercurial, >> it would make things easier for me. It takes me forever to make a >> patch and I am not even sure it can be used. > > Jukka maintains a git mirror of apache at http://jukka.zitting.name/git/ I have setup my own repository to make working on mod_lua easier for me: http://mamasam.indefero.net/p/modlua/source/changes/mansion/ -- Bertrand Mansion Mamasam