lua-users home
lua-l archive

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

On Feb 23, 2005, at 11:57, Luiz Henrique de Figueiredo wrote:

By the way, would it be safe to, er, redefine the error() function to
not stop the interpreter?

There are two misconceptions here. First, the error function does not stop
the interpreter, it only aborts the current chunk.

Ok. What precisely is a "chunk" then? I start my Lua application like this:

lua Main.lua

If anything unexpected happens in Main.lua, the interpreter exits, right? I would like to avoid this. How?

 Second, not all errors
are raised by calling error(). Actually, most aren't.

Ok... so... what should one do to handle errors in a more graceful manner? If a native C module decides to unitarily trash the VM, so be it. But if an exception emanate from a Lua piece of code, I would like to be able to handle it one way or another so the VM keeps running. How can I do that?

In a nutshell, I would rather not have the VM simply quit for random reasons. I would much prefer to have the possibility to have a say in deciding if a so called error warrant the termination of the VM, chunked or not. What would be a good way to achieve this?


PA, Onnay Equitursay