Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
55.00% |
11 / 20 |
|
18.18% |
2 / 11 |
CRAP | |
0.00% |
0 / 1 |
| AppErrorHandler | |
52.63% |
10 / 19 |
|
18.18% |
2 / 11 |
30.96 | |
0.00% |
0 / 1 |
| renderError | |
88.89% |
8 / 9 |
|
0.00% |
0 / 1 |
3.01 | |||
| error400 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| error404 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| error500 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| notFound | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| missingController | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| missingAction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| badRequest | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| forbidden | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| methodNotAllowed | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| internalError | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | App::uses('ExceptionRenderer', 'Error'); |
| 4 | |
| 5 | class AppErrorHandler extends ExceptionRenderer |
| 6 | { |
| 7 | private function renderError($error) |
| 8 | { |
| 9 | $code = $error->getCode(); |
| 10 | // Plain Exception has code 0, MissingController/Action have non-HTTP codes |
| 11 | if ($code < 400 || $code >= 600) |
| 12 | $code = 500; |
| 13 | $this->controller->response->statusCode($code); |
| 14 | $this->controller->set([ |
| 15 | 'url' => $this->controller->request->here, |
| 16 | 'error' => $error |
| 17 | ]); |
| 18 | $this->_outputMessage('error'); |
| 19 | } |
| 20 | |
| 21 | public function error400($error) |
| 22 | { |
| 23 | $this->renderError($error); |
| 24 | } |
| 25 | |
| 26 | public function error404($error) |
| 27 | { |
| 28 | $this->renderError($error); |
| 29 | } |
| 30 | |
| 31 | public function error500($error) |
| 32 | { |
| 33 | $this->renderError($error); |
| 34 | } |
| 35 | |
| 36 | public function notFound($error) |
| 37 | { |
| 38 | $this->renderError($error); |
| 39 | } |
| 40 | |
| 41 | public function missingController($error) |
| 42 | { |
| 43 | $this->renderError($error); |
| 44 | } |
| 45 | |
| 46 | public function missingAction($error) |
| 47 | { |
| 48 | $this->renderError($error); |
| 49 | } |
| 50 | |
| 51 | public function badRequest($error) |
| 52 | { |
| 53 | $this->renderError($error); |
| 54 | } |
| 55 | |
| 56 | public function forbidden($error) |
| 57 | { |
| 58 | $this->renderError($error); |
| 59 | } |
| 60 | |
| 61 | public function methodNotAllowed($error) |
| 62 | { |
| 63 | $this->renderError($error); |
| 64 | } |
| 65 | |
| 66 | public function internalError($error) |
| 67 | { |
| 68 | $this->renderError($error); |
| 69 | } |
| 70 | } |