Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AppErrorHandler
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3App::uses('AppException', 'Utility');
4
5class AppErrorHandler
6{
7    public $exception;
8
9    public function __construct($exception)
10    {
11        $this->exception = $exception;
12    }
13
14    public function render()
15    {
16        if ($this->exception instanceof MissingControllerException)
17        {
18            header('HTTP/1.1 404 Page not found    ');
19            echo "404 Error - Page not found";
20            exit;
21        }
22
23        // Build the exception message
24        $message = $this->exception->getMessage() . "<br>\n";
25        $message .= "#-1 " . $this->exception->getFile() . "(" . $this->exception->getLine() . ")<br>\n";
26
27        if (!($this->exception instanceof AppException))
28        {
29            $message = "<h2>Exception</h2><br>\n" . $message;
30            $message .= nl2br(htmlspecialchars($this->exception->getTraceAsString()));
31        }
32
33        // Output and terminate
34        echo $message;
35        exit;
36    }
37}