revIgniter lets you build error reporting into your applications using the handlers described below. In addition, it has an error logging library that permits error and debugging messages to be saved as text files.
Note: By default, revIgniter displays all LiveCode errors. You might wish to change this behavior once your development is complete. You'll find the errorMode setting in the application/config/config.lc file. Disabling error reporting will NOT prevent log files from being written if there are errors.
Error handlers are available globally throughout the application. These do not require loading any libraries or helpers
The following handlers let you generate errors:
rigShowError "message" [, statusCode ]
This handler will display the error message supplied to it using the following error template:
The optional parameter statusCode determines what HTTP status code should be sent with the error.
This handler will display the 404 error message supplied to it using the following error template:
The handler expects the string passed to it to be the file path to the page that isn't found. Note that revIgniter automatically shows 404 messages if controllers are not found.
Note:You can write your own 404 error controller using a routing rule overriding the default 404 error page. This won't affect to the rigShow404 handler, which will continue loading the default error404.lc file at system/application/errors/error404.lc. Please see the URI Routing section of the User Guide.
rigLogMessage "level", "message", "displayError"
This handler lets you write messages to your log files. You must supply one of three "levels" in the first parameter, indicating what type of message it is (debug, error, info), with the message itself in the second parameter and a boolean in the optional third paramater, which indicates if the error should be displayed in an error page. Example:
if tSomeVar = "" then rigLogMessage "error", "Some variable did not contain a value." else rigLogMessage "debug", "Some variable was correctly set." end if rigLogMessage "info", "The purpose of some variable is to provide some value."
There are three message types:
- Error Messages. These are actual errors, such as user errors.
- Debug Messages. These are messages that assist in debugging. For example, if a library has been loaded, you could log this as debugging info.
- Informational Messages. These are the lowest priority messages, simply giving information regarding some process. revIgniter doesn't natively generate any info messages but you may want to in your application.
Note: In order for the log file to actually be written, the "logs" folder must be writable. In addition, you must set the "threshold" for logging. You might, for example, only want error messages to be logged, and not the other two types. If you set it to zero logging will be disabled.
rigDoException Contexts, CurrentFile, CurrentHandler
Try Catch statement error reporting displaying an error page:
try put 2 / 0 into tDivision catch tContexts put "errortest.lc" into tCurrentFile put "index" into tCurrentHandler rigDoException tContexts, tCurrentFile, tCurrentHandler end try
Where "errortest.lc" is the name of the controller file and "index" is the executing handler.
Note: To send the error output to the browser the error logging threshold in config.lc must be set to 1 or higher. The rigDoException handler overrides the LiveCode errormode error handling.