Changing Default Error Reporting Mode

From OpenEUO
Revision as of 18:33, 1 November 2010 by Ximan (Talk | contribs)

Jump to: navigation, search

By default, every error (whether or not fatal) detected by the library at run time is logged into an internal error table and an error message is generated for the user. There are two non-exclusive manners for reporting errors: printing to the script's output window and logging to an error file. Either can be toggled on or off separately (see slredirect) and the manner of reporting may additionally be influenced by the error verbosity level (see slverbosity).

After a detected error is recorded, then one of three modes of error handling is invoked: reraise (the default), inline, or callback. The error handling mode may be switched using the slredirect method.

Reraise

Upon library initialization, the default error handling procedure is to reraise any encountered error, whether the underlying error is fatal or not.

Inline

To allow more fluid operation, detected errors may be handled by the library and the usual results of a function in an error condition is supplanted with an error result tuple (ERR,eref), where ERR is a unique library defined value, and eref is a number which can be used as an argument to geterror to retrieve the recorded error table. Alternatively, the error result be set to return (nil, eref) a more standard lua form.

Callback

The final error handling mode allows the user to specify a callback function. If specified and enabled, this callback will be invoked after the error is recorded, and the result of the callback function supplants the usual return values of the function at error.

See Also