|
1 | 1 | <h1>A 404 error occurred</h1> |
2 | 2 | <h2><?= $this->message ?></h2> |
3 | 3 |
|
4 | | -<?php if (isset($this->reason) && $this->reason): ?> |
5 | | - |
6 | | -<?php |
7 | | -$reasonMessage= ''; |
8 | | -switch ($this->reason) { |
9 | | - case 'error-controller-cannot-dispatch': |
10 | | - $reasonMessage = 'The requested controller was unable to dispatch the request.'; |
11 | | - break; |
12 | | - case 'error-controller-not-found': |
13 | | - $reasonMessage = 'The requested controller could not be mapped to an existing controller class.'; |
14 | | - break; |
15 | | - case 'error-controller-invalid': |
16 | | - $reasonMessage = 'The requested controller was not dispatchable.'; |
17 | | - break; |
18 | | - case 'error-router-no-match': |
19 | | - $reasonMessage = 'The requested URL could not be matched by routing.'; |
20 | | - break; |
21 | | - default: |
22 | | - $reasonMessage = 'We cannot determine at this time why a 404 was generated.'; |
23 | | - break; |
24 | | -} |
25 | | -?> |
26 | | - |
27 | | -<p><?= $reasonMessage ?></p> |
28 | | - |
| 4 | +<?php if (!empty($this->reason)) : ?> |
| 5 | + <?php |
| 6 | + switch ($this->reason) { |
| 7 | + case \Zend\Mvc\Application::ERROR_CONTROLLER_CANNOT_DISPATCH: |
| 8 | + $reasonMessage = 'The requested controller was unable to dispatch the request.'; |
| 9 | + break; |
| 10 | + case \Zend\Mvc\Application::ERROR_MIDDLEWARE_CANNOT_DISPATCH: |
| 11 | + $reasonMessage = 'The requested middleware was unable to dispatch the request.'; |
| 12 | + break; |
| 13 | + case \Zend\Mvc\Application::ERROR_CONTROLLER_NOT_FOUND: |
| 14 | + $reasonMessage = 'The requested controller could not be mapped to an existing controller class.'; |
| 15 | + break; |
| 16 | + case \Zend\Mvc\Application::ERROR_CONTROLLER_INVALID: |
| 17 | + $reasonMessage = 'The requested controller was not dispatchable.'; |
| 18 | + break; |
| 19 | + case \Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH: |
| 20 | + $reasonMessage = 'The requested URL could not be matched by routing.'; |
| 21 | + break; |
| 22 | + default: |
| 23 | + $reasonMessage = 'We cannot determine at this time why a 404 was generated.'; |
| 24 | + break; |
| 25 | + } |
| 26 | + ?> |
| 27 | + <p><?= $reasonMessage ?></p> |
29 | 28 | <?php endif ?> |
30 | 29 |
|
31 | | -<?php if (isset($this->controller) && $this->controller): ?> |
32 | | - |
33 | | -<dl> |
34 | | - <dt>Controller:</dt> |
35 | | - <dd><?= $this->escapeHtml($this->controller) ?> |
36 | | -<?php |
37 | | -if (isset($this->controller_class) |
38 | | - && $this->controller_class |
39 | | - && $this->controller_class != $this->controller |
40 | | -) { |
41 | | - echo '(' . sprintf('resolves to %s', $this->escapeHtml($this->controller_class)) . ')'; |
42 | | -} |
43 | | -?> |
44 | | -</dd> |
45 | | -</dl> |
46 | | - |
| 30 | +<?php if (isset($this->controller) && $this->controller) : ?> |
| 31 | + <dl> |
| 32 | + <dt>Controller:</dt> |
| 33 | + <dd> |
| 34 | + <?= $this->escapeHtml($this->controller) ?> |
| 35 | + <?php |
| 36 | + if (isset($this->controller_class) |
| 37 | + && $this->controller_class |
| 38 | + && $this->controller_class != $this->controller |
| 39 | + ) { |
| 40 | + echo '(' . sprintf('resolves to %s', $this->escapeHtml($this->controller_class)) . ')'; |
| 41 | + } |
| 42 | + ?> |
| 43 | + </dd> |
| 44 | + </dl> |
47 | 45 | <?php endif ?> |
48 | 46 |
|
49 | | -<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?> |
| 47 | +<?php if (isset($this->display_exceptions) && $this->display_exceptions) : ?> |
| 48 | + <?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?> |
| 49 | + <hr/> |
50 | 50 |
|
51 | | -<?php if(isset($this->exception) && ($this->exception instanceof Exception || $this->exception instanceof Error)): ?> |
52 | | -<hr/> |
53 | | -<h2>Additional information:</h2> |
54 | | -<h3><?= get_class($this->exception) ?></h3> |
55 | | -<dl> |
56 | | - <dt>File:</dt> |
57 | | - <dd> |
58 | | - <pre class="prettyprint linenums"><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre> |
59 | | - </dd> |
60 | | - <dt>Message:</dt> |
61 | | - <dd> |
62 | | - <pre class="prettyprint linenums"><?= $this->exception->getMessage() ?></pre> |
63 | | - </dd> |
64 | | - <dt>Stack trace:</dt> |
65 | | - <dd> |
66 | | - <pre class="prettyprint linenums"><?= $this->exception->getTraceAsString() ?></pre> |
67 | | - </dd> |
68 | | -</dl> |
69 | | -<?php |
70 | | - $e = $this->exception->getPrevious(); |
71 | | - $icount = 0; |
72 | | - if ($e) : |
73 | | -?> |
74 | | -<hr/> |
75 | | -<h2>Previous exceptions:</h2> |
76 | | -<ul class="unstyled"> |
77 | | - <?php while($e) : ?> |
78 | | - <li> |
79 | | - <h3><?= get_class($e) ?></h3> |
| 51 | + <h2>Additional information:</h2> |
| 52 | + <h3><?= get_class($this->exception) ?></h3> |
80 | 53 | <dl> |
81 | 54 | <dt>File:</dt> |
82 | 55 | <dd> |
83 | | - <pre class="prettyprint linenums"><?= $e->getFile() ?>:<?= $e->getLine() ?></pre> |
| 56 | + <pre><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre> |
84 | 57 | </dd> |
85 | 58 | <dt>Message:</dt> |
86 | 59 | <dd> |
87 | | - <pre class="prettyprint linenums"><?= $e->getMessage() ?></pre> |
| 60 | + <pre><?= $this->escapeHtml($this->exception->getMessage()) ?></pre> |
88 | 61 | </dd> |
89 | 62 | <dt>Stack trace:</dt> |
90 | 63 | <dd> |
91 | | - <pre class="prettyprint linenums"><?= $e->getTraceAsString() ?></pre> |
| 64 | + <pre><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre> |
92 | 65 | </dd> |
93 | 66 | </dl> |
94 | | - </li> |
95 | | - <?php |
96 | | - $e = $e->getPrevious(); |
97 | | - $icount += 1; |
98 | | - if ($icount >=50) { |
99 | | - echo "<li>There may be more exceptions, but we have no enough memory to proccess it.</li>"; |
100 | | - break; |
101 | | - } |
102 | | - endwhile; |
103 | | - ?> |
104 | | -</ul> |
105 | | -<?php endif; ?> |
106 | | - |
107 | | -<?php else: ?> |
108 | 67 |
|
109 | | -<h3>No Exception available</h3> |
110 | | - |
111 | | -<?php endif ?> |
| 68 | + <?php if ($ex = $this->exception->getPrevious()) : ?> |
| 69 | + <hr/> |
112 | 70 |
|
| 71 | + <h2>Previous exceptions:</h2> |
| 72 | + <ul class="list-unstyled"> |
| 73 | + <?php $icount = 0; ?> |
| 74 | + <?php while ($ex) : ?> |
| 75 | + <li> |
| 76 | + <h3><?= get_class($ex) ?></h3> |
| 77 | + <dl> |
| 78 | + <dt>File:</dt> |
| 79 | + <dd> |
| 80 | + <pre><?= $ex->getFile() ?>:<?= $ex->getLine() ?></pre> |
| 81 | + </dd> |
| 82 | + <dt>Message:</dt> |
| 83 | + <dd> |
| 84 | + <pre><?= $this->escapeHtml($ex->getMessage()) ?></pre> |
| 85 | + </dd> |
| 86 | + <dt>Stack trace:</dt> |
| 87 | + <dd> |
| 88 | + <pre><?= $this->escapeHtml($ex->getTraceAsString()) ?></pre> |
| 89 | + </dd> |
| 90 | + </dl> |
| 91 | + </li> |
| 92 | + <?php |
| 93 | + $ex = $ex->getPrevious(); |
| 94 | + if (++$icount >= 50) { |
| 95 | + echo '<li>There may be more exceptions, but we have no enough memory to proccess it.</li>'; |
| 96 | + break; |
| 97 | + } |
| 98 | + ?> |
| 99 | + <?php endwhile ?> |
| 100 | + </ul> |
| 101 | + <?php endif ?> |
| 102 | + <?php else: ?> |
| 103 | + <h3>No Exception available</h3> |
| 104 | + <?php endif ?> |
113 | 105 | <?php endif ?> |
0 commit comments