When
we invoke any of the raise methods we pass two parameters, an error code and an
error message.
The error code is a string that is used to identify the error. Error codes are rendered
using one of three templates 403.php, 404.php, and 500.php. If the error code is 403
(Access Denied) or 404 (Page could not be found), we use the 403.php and 404.php
templates respectively. These templates include some additional standard text that
describes the normal reasons for receiving a 403 or a 404 error. All other error codes
use the 500.php (Internal Server Error) template:
JError::raiseError('403', JText::_('Access Forbidden'));
Chapter 11
[ 313 ]
JError::raiseError('500', JText::_('An error has occurred.'));
Level E_ERROR errors (JError::raiseError()), are for fatal errors. When a non fatal
error occurs we can use the weaker, warning and notice levels. These two levels are
handled in the same way, but it is still useful to make the distinction between the
two; it helps aid classification of errors and the process of debugging:
JError::raiseWarning('ERROR_CODE', JText::_('Look out! There is a
giant boxing kangaroo behind you!'));
This is perhaps not the most useful of messages and perhaps a little unlikely,
but you get the idea.
Pages:
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428