We can test the return value of a method to see if it is an error using the
JError::isError() method. As an example, the JController execute() method
returns an error if no method is mapped to the task we try to execute:
$result = $SomeCOntroller->execute('someTask');
if(JError::isError($result))
{
// handle invalid task
}
Customizing Error Handling
The handling of errors is not set in stone. We can modify the way each of the levels
is handled and we can add new levels. We can choose any of the following modes
(maximum of one mode per error level):
Mode Description
Ignore Error is ignored
Echo Prints the JException message to screen
Verbose Prints the JException message and back-trace information to screen
Die Terminates the application and prints the JException message to screen
Message Adds a message to the application queue
Log Adds a log entry to the application error log
Trigger Triggers a PHP error
Callback Calls a static method in another class
To modify the error handling of an existing error level we can use the JError::
setErrorHandling() method.
Pages:
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430