Let's start by creating a simple view that will display errors to us.
1. Let's start by creating a new folder called
error
inside ourviews
directory.2. Create a new view called
500.php
, and place it into theerrors
folder (views/error/500.php).3. Add the following code to the
500.php
output information on the exception:<div class="hero-unit"> <h1>An Error Has Occurred</h1> <p> <strong>Code:</strong><?php echo $exception->getCode(); ?> </p> <p> <strong>Message:</strong> <?php echo $exception->getMessage(); ?> </p> <p><strong>Exception:</strong> <?php echo $exception; ?></p> </div>
4. Add a function called
error500
inlib/bones.php
that will allow us to display 500 errors easily around our application.public function error500($exception) { $this->set('exception', $exception); $this->render('error/500'); exit; }