This example redefines the notice error to use the
Ignore mode. Some modes require a third parameter, an array of options specific to
the mode:
JError::setErrorHandling(E_NOTICE, 'Ignore');
To define a new error level we can use the JError::registerErrorLevel()
method. If the error level is already defined the method will return false:
define('MY_ERROR', 666);
if( !JError::registerErrorLevel(MY_ERROR, 'My Extension Error',
'Message') )
{
JError::raiseError('SOME_ERROR', JText::_('Error level already
defined').' ['.MY_ERROR.']');
}
Chapter 11
[ 315 ]
Once we have defined a new error level, to raise an error of that level we can use the
JError::raise() method. The raise() method can be used with any of the defined
error levels, including E_ERROR, E_WARNING, and E_NOTICE:
JError::raise(MYEXT_ERROR, 'SOME_ERROR', JText::_('Look out!
It\'s those boxing kangaroos again!'));
Dealing with CGI Request Data
It is essential that we sanitize incoming data (i.e. remove any unexpected data and
ensure the data is of an expected type).
Pages:
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431