HTML and CSS Reference
In-Depth Information
Adding an Error Handler
Next, the app needs an error handler. Currently, if a non-working URI is visited (such as http://rwa.loca/not-real/ )
there is an ugly “uncaught exception” error message displayed (see Figure 8-2 ).
Figure 8-2. Non-working URIs cause ugly errors to be displayed
The app is already attempting to load the Error class if something goes wrong, so all you need to do is build that
controller and view to catch the errors and display them in an easy-to-read manner.
Creating the Error Controller
To begin, create a new file called class.error.inc.php and save it in system/controllers/ . Inside, place the following code:
<?php
/**
* Processes output for the Room view
*
* @author Jason Lengstorf <jason@lengstorf.com>
* @author Phil Leggetter <phil@leggetter.co.uk>
*/
class Error extends Controller
{
private $_message = NULL;
/**
* Initializes the view
*
* @param $options array Options for the view
* @return void
*/
public function __construct( $options )
{
if (isset($options[1])) {
$this->_message = $options[1];
}
}
/**
* Generates the title of the page
*
* @return string The title of the page
*/
 
Search WWH ::




Custom Search