lua-users home
lua-l archive

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


>From: Ken Rawlings <krawling@bluemarble.net>
>
>   Finally, how do people do error handling with complicated applications
>   in Lua? Correct me if i'm wrong, but error() stops the interpreter,
>   which is often not what you want. Is there a way to implement some sort
>   of simplified exception handling, perhaps with tag methods?

When an error occurs, the execution of the current function or chunk ends.
The only thing you can do when in error occurs is to do something to or with
the error message: displaying it somewhere else, not displaying it all,
modifying it, looking at it and setting some flag, etc.
This is the job of _ALERT and _ERRORMESSAGE, which you can redefine to do
whatever you want.
But you cannot return to the point where the error occured and continue
execution. (How would Lua continue?)

Perhaps you could give examples of the complicated error handling you have
in mind.
--lhf