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

Commit 74cb82f

Browse files
committed
Merge pull request #344 from webimpress/error-views
Error views updated
2 parents 7dde5be + 7e7597f commit 74cb82f

File tree

2 files changed

+127
-141
lines changed

2 files changed

+127
-141
lines changed
Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,105 @@
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-
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>
2928
<?php endif ?>
3029

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>
4745
<?php endif ?>
4846

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/>
5050

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>
8053
<dl>
8154
<dt>File:</dt>
8255
<dd>
83-
<pre class="prettyprint linenums"><?= $e->getFile() ?>:<?= $e->getLine() ?></pre>
56+
<pre><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
8457
</dd>
8558
<dt>Message:</dt>
8659
<dd>
87-
<pre class="prettyprint linenums"><?= $e->getMessage() ?></pre>
60+
<pre><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
8861
</dd>
8962
<dt>Stack trace:</dt>
9063
<dd>
91-
<pre class="prettyprint linenums"><?= $e->getTraceAsString() ?></pre>
64+
<pre><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
9265
</dd>
9366
</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: ?>
10867

109-
<h3>No Exception available</h3>
110-
111-
<?php endif ?>
68+
<?php if ($ex = $this->exception->getPrevious()) : ?>
69+
<hr/>
11270

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 ?>
113105
<?php endif ?>
Lines changed: 44 additions & 50 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): ?>
4+
<?php if (isset($this->display_exceptions) && $this->display_exceptions) : ?>
5+
<?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?>
6+
<hr/>
57

6-
<?php if(isset($this->exception) && ($this->exception instanceof Exception || $this->exception instanceof Error)): ?>
7-
<hr/>
8-
<h2>Additional information:</h2>
9-
<h3><?= get_class($this->exception) ?></h3>
10-
<dl>
11-
<dt>File:</dt>
12-
<dd>
13-
<pre class="prettyprint linenums"><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
14-
</dd>
15-
<dt>Message:</dt>
16-
<dd>
17-
<pre class="prettyprint linenums"><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
18-
</dd>
19-
<dt>Stack trace:</dt>
20-
<dd>
21-
<pre class="prettyprint linenums"><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
22-
</dd>
23-
</dl>
24-
<?php
25-
$e = $this->exception->getPrevious();
26-
$icount = 0;
27-
if ($e) :
28-
?>
29-
<hr/>
30-
<h2>Previous exceptions:</h2>
31-
<ul class="unstyled">
32-
<?php while($e) : ?>
33-
<li>
34-
<h3><?= get_class($e) ?></h3>
8+
<h2>Additional information:</h2>
9+
<h3><?= get_class($this->exception) ?></h3>
3510
<dl>
3611
<dt>File:</dt>
3712
<dd>
38-
<pre class="prettyprint linenums"><?= $e->getFile() ?>:<?= $e->getLine() ?></pre>
13+
<pre><?= $this->exception->getFile() ?>:<?= $this->exception->getLine() ?></pre>
3914
</dd>
4015
<dt>Message:</dt>
4116
<dd>
42-
<pre class="prettyprint linenums"><?= $this->escapeHtml($e->getMessage()) ?></pre>
17+
<pre><?= $this->escapeHtml($this->exception->getMessage()) ?></pre>
4318
</dd>
4419
<dt>Stack trace:</dt>
4520
<dd>
46-
<pre class="prettyprint linenums"><?= $this->escapeHtml($e->getTraceAsString()) ?></pre>
21+
<pre><?= $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
4722
</dd>
4823
</dl>
49-
</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-
?>
59-
</ul>
60-
<?php endif; ?>
6124

62-
<?php else: ?>
63-
64-
<h3>No Exception available</h3>
65-
66-
<?php endif ?>
25+
<?php if ($ex = $this->exception->getPrevious()) : ?>
26+
<hr/>
6727

28+
<h2>Previous exceptions:</h2>
29+
<ul class="list-unstyled">
30+
<?php $icount = 0; ?>
31+
<?php while ($ex) : ?>
32+
<li>
33+
<h3><?= get_class($ex) ?></h3>
34+
<dl>
35+
<dt>File:</dt>
36+
<dd>
37+
<pre><?= $ex->getFile() ?>:<?= $ex->getLine() ?></pre>
38+
</dd>
39+
<dt>Message:</dt>
40+
<dd>
41+
<pre><?= $this->escapeHtml($ex->getMessage()) ?></pre>
42+
</dd>
43+
<dt>Stack trace:</dt>
44+
<dd>
45+
<pre><?= $this->escapeHtml($ex->getTraceAsString()) ?></pre>
46+
</dd>
47+
</dl>
48+
</li>
49+
<?php
50+
$ex = $ex->getPrevious();
51+
if (++$icount >= 50) {
52+
echo '<li>There may be more exceptions, but we have no enough memory to proccess it.</li>';
53+
break;
54+
}
55+
?>
56+
<?php endwhile ?>
57+
</ul>
58+
<?php endif ?>
59+
<?php else: ?>
60+
<h3>No Exception available</h3>
61+
<?php endif ?>
6862
<?php endif ?>

0 commit comments

Comments
 (0)