[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: catching errors?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 19 Aug 1999 10:39:13 -0300 (EST)
>From firstname.lastname@example.org Thu Aug 19 10:22:32 1999
>From: "Brian J. Swetland" <email@example.com>
>What's the best place to hook into lua's internal error mechanisms?
>Does everything go through error() at some point or is there something
>lower down that's better to use?
Everything goes through _ERRORMESSAGE.
To quote the manual:
4.9 - Error Handling
Because Lua is an extension language, all Lua actions start from C code
in the host program calling a function from the Lua library. Whenever
an error occurs during Lua compilation or execution, function
_ERRORMESSAGE is called (provided it is different from nil), and then
the corresponding function from the library (lua_dofile, lua_dostring,
lua_dobuffer, or lua_callfunction) is terminated, returning an error
The only argument to _ERRORMESSAGE is a string describing the error.
The default definition for this function calls _ALERT, which prints the
message to stderr (see Section 6.1). The standard I/O library redefines
_ERRORMESSAGE, and uses the debug facilities (see Section 7) to print
some extra information, such as the call stack.
In other words: If you want to change the way the messages are displayed,
redefine _ALERT. For example, you might want to display the message in a
dialog box or write it to a file.
On the other hand, to catch errors, redefine _ERRORMESSAGE.