lua-users home
lua-l archive

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


> > The solution I found is similar to the one you
> > already described: just make
> > sure you register your own print replacement (for
> > debugging &c.) and[!] a
> > function to handle _ALERT. The latter is the
> > function that gets called
> > whenever Lua (v4) outputs any errors. I found that
> > redefining these 2
> > functions prevented my Lua GUI host app from taking
> > unexpected nose dives.
>
> I'm still using Lua 4 too. Can you tell me more about
> _ALERT? I don't know about it, and I don't remember
> seeing it in any of the Lua documentation I have.

I guess the best thing to do if you want to know about _ALERT is to look at
lbaselib.c and liolib.c. You can find them in Lua's src/lib directory (from
Lua 4's source distribution). There are very few references, so it won't
take long.

Both modules provide error handlers (luaB__ERRORMESSAGE and errorfb, resp.)
implementing Lua's _ERRORMESSAGE. These handlers use _ALERT to output error
messages. The provided _ALERT implementation (luaB__ALERT) outputs to
stderr.

By redefining _ALERT you make sure the error messages end up where they need
to. For instance, wiring _ALERT to a function that calls Windows' MessageBox
function should give you some decent default behaviour.

Ashwin.