Skip to content
This repository was archived by the owner on Jan 1, 2020. It is now read-only.

Commit 3ab094b

Browse files
committed
Merge branch 'hotfix/344'
Close #344
2 parents 7dde5be + c039c51 commit 3ab094b

File tree

2 files changed

+87
-104
lines changed

2 files changed

+87
-104
lines changed
Lines changed: 59 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,102 @@
11
<h1>A 404 error occurred</h1>
22
<h2><?= $this->message ?></h2>
33

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-
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+
?>
2727
<p><?= $reasonMessage ?></p>
28-
2928
<?php endif ?>
3029

31-
<?php if (isset($this->controller) && $this->controller): ?>
32-
30+
<?php if (! empty($this->controller)) : ?>
3331
<dl>
3432
<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>
33+
<dd>
34+
<?= $this->escapeHtml($this->controller) ?>
35+
<?php
36+
if (! empty($this->controller_class) && $this->controller_class != $this->controller) {
37+
printf('(resolves to %s)', $this->escapeHtml($this->controller_class));
38+
}
39+
?>
40+
</dd>
4541
</dl>
46-
4742
<?php endif ?>
4843

49-
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
50-
51-
<?php if(isset($this->exception) && ($this->exception instanceof Exception || $this->exception instanceof Error)): ?>
44+
<?php if (! empty($this->display_exceptions)) : ?>
45+
<?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?>
5246
<hr/>
47+
5348
<h2>Additional information:</h2>
5449
<h3><?= get_class($this->exception) ?></h3>
5550
<dl>
5651
<dt>File:</dt>
5752
<dd>
58-
<pre class="prettyprint linenums"><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
53+
<pre><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
5954
</dd>
6055
<dt>Message:</dt>
6156
<dd>
62-
<pre class="prettyprint linenums"><?= $this->exception->getMessage() ?></pre>
57+
<pre><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
6358
</dd>
6459
<dt>Stack trace:</dt>
6560
<dd>
66-
<pre class="prettyprint linenums"><?= $this->exception->getTraceAsString() ?></pre>
61+
<pre><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
6762
</dd>
6863
</dl>
69-
<?php
70-
$e = $this->exception->getPrevious();
71-
$icount = 0;
72-
if ($e) :
73-
?>
64+
65+
<?php if ($ex = $this->exception->getPrevious()) : ?>
7466
<hr/>
67+
7568
<h2>Previous exceptions:</h2>
76-
<ul class="unstyled">
77-
<?php while($e) : ?>
69+
<ul class="list-unstyled">
70+
<?php $icount = 0 ?>
71+
<?php while ($ex) : ?>
7872
<li>
79-
<h3><?= get_class($e) ?></h3>
73+
<h3><?= get_class($ex) ?></h3>
8074
<dl>
8175
<dt>File:</dt>
8276
<dd>
83-
<pre class="prettyprint linenums"><?= $e->getFile() ?>:<?= $e->getLine() ?></pre>
77+
<pre><?= $ex->getFile() ?>:<?= $ex->getLine() ?></pre>
8478
</dd>
8579
<dt>Message:</dt>
8680
<dd>
87-
<pre class="prettyprint linenums"><?= $e->getMessage() ?></pre>
81+
<pre><?= $this->escapeHtml($ex->getMessage()) ?></pre>
8882
</dd>
8983
<dt>Stack trace:</dt>
9084
<dd>
91-
<pre class="prettyprint linenums"><?= $e->getTraceAsString() ?></pre>
85+
<pre><?= $this->escapeHtml($ex->getTraceAsString()) ?></pre>
9286
</dd>
9387
</dl>
9488
</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-
?>
89+
<?php
90+
$ex = $ex->getPrevious();
91+
if (++$icount >= 50) {
92+
echo '<li>There may be more exceptions, but we do not have enough memory to process it.</li>';
93+
break;
94+
}
95+
?>
96+
<?php endwhile ?>
10497
</ul>
105-
<?php endif; ?>
106-
107-
<?php else: ?>
108-
98+
<?php endif ?>
99+
<?php else : ?>
109100
<h3>No Exception available</h3>
110-
111-
<?php endif ?>
112-
101+
<?php endif ?>
113102
<?php endif ?>
Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,62 @@
11
<h1>An error occurred</h1>
22
<h2><?= $this->message ?></h2>
33

4-
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
5-
6-
<?php if(isset($this->exception) && ($this->exception instanceof Exception || $this->exception instanceof Error)): ?>
4+
<?php if (! empty($this->display_exceptions)) : ?>
5+
<?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?>
76
<hr/>
7+
88
<h2>Additional information:</h2>
99
<h3><?= get_class($this->exception) ?></h3>
1010
<dl>
1111
<dt>File:</dt>
1212
<dd>
13-
<pre class="prettyprint linenums"><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
13+
<pre><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
1414
</dd>
1515
<dt>Message:</dt>
1616
<dd>
17-
<pre class="prettyprint linenums"><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
17+
<pre><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
1818
</dd>
1919
<dt>Stack trace:</dt>
2020
<dd>
21-
<pre class="prettyprint linenums"><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
21+
<pre><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
2222
</dd>
2323
</dl>
24-
<?php
25-
$e = $this->exception->getPrevious();
26-
$icount = 0;
27-
if ($e) :
28-
?>
24+
25+
<?php if ($ex = $this->exception->getPrevious()) : ?>
2926
<hr/>
27+
3028
<h2>Previous exceptions:</h2>
31-
<ul class="unstyled">
32-
<?php while($e) : ?>
29+
<ul class="list-unstyled">
30+
<?php $icount = 0 ?>
31+
<?php while ($ex) : ?>
3332
<li>
34-
<h3><?= get_class($e) ?></h3>
33+
<h3><?= get_class($ex) ?></h3>
3534
<dl>
3635
<dt>File:</dt>
3736
<dd>
38-
<pre class="prettyprint linenums"><?= $e->getFile() ?>:<?= $e->getLine() ?></pre>
37+
<pre><?= $ex->getFile() ?>:<?= $ex->getLine() ?></pre>
3938
</dd>
4039
<dt>Message:</dt>
4140
<dd>
42-
<pre class="prettyprint linenums"><?= $this->escapeHtml($e->getMessage()) ?></pre>
41+
<pre><?= $this->escapeHtml($ex->getMessage()) ?></pre>
4342
</dd>
4443
<dt>Stack trace:</dt>
4544
<dd>
46-
<pre class="prettyprint linenums"><?= $this->escapeHtml($e->getTraceAsString()) ?></pre>
45+
<pre><?= $this->escapeHtml($ex->getTraceAsString()) ?></pre>
4746
</dd>
4847
</dl>
4948
</li>
50-
<?php
51-
$e = $e->getPrevious();
52-
$icount += 1;
53-
if ($icount >= 50) {
54-
echo "<li>There may be more exceptions, but we have no enough memory to proccess it.</li>";
55-
break;
56-
}
57-
endwhile;
58-
?>
49+
<?php
50+
$ex = $ex->getPrevious();
51+
if (++$icount >= 50) {
52+
echo '<li>There may be more exceptions, but we do not have enough memory to process it.</li>';
53+
break;
54+
}
55+
?>
56+
<?php endwhile ?>
5957
</ul>
60-
<?php endif; ?>
61-
62-
<?php else: ?>
63-
64-
<h3>No Exception available</h3>
65-
66-
<?php endif ?>
67-
58+
<?php endif ?>
59+
<?php else : ?>
60+
<h3>No Exception available</h3>
61+
<?php endif ?>
6862
<?php endif ?>

0 commit comments

Comments
 (0)