O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — handling 500 errors with Bones

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 our views directory.
  2. Create a new view called 500.php, and place it into the errors 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 in lib/bones.php that will allow us to display 500 errors easily around our application.
    public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required