Skip to content

Commit 5059ced

Browse files
committed
Merge pull request #1413 from machuga/develop
Add 500 response code to exception handler. -- machuga, JesseOBrien, sde...
2 parents d693a82 + 24ba947 commit 5059ced

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

laravel/error.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,23 @@ public static function exception($exception, $trace = true)
3030
// If detailed errors are enabled, we'll just format the exception into
3131
// a simple error message and display it on the screen. We don't use a
3232
// View in case the problem is in the View class.
33+
3334
if (Config::get('error.detail'))
3435
{
35-
echo "<html><h2>Unhandled Exception</h2>
36-
<h3>Message:</h3>
37-
<pre>".$message."</pre>
38-
<h3>Location:</h3>
39-
<pre>".$file." on line ".$exception->getLine()."</pre>";
36+
$response_body = "<html><h2>Unhandled Exception</h2>
37+
<h3>Message:</h3>
38+
<pre>".$message."</pre>
39+
<h3>Location:</h3>
40+
<pre>".$file." on line ".$exception->getLine()."</pre>";
4041

4142
if ($trace)
4243
{
43-
echo "
44+
$response_body .= "
4445
<h3>Stack Trace:</h3>
4546
<pre>".$exception->getTraceAsString()."</pre></html>";
4647
}
48+
49+
$response = Response::make($response_body, 500);
4750
}
4851

4952
// If we're not using detailed error messages, we'll use the event
@@ -53,9 +56,13 @@ public static function exception($exception, $trace = true)
5356
{
5457
$response = Event::first('500');
5558

56-
echo Response::prepare($response)->render();
59+
$response = Response::prepare($response);
5760
}
5861

62+
$response->render();
63+
$response->send();
64+
$response->foundation->finish();
65+
5966
exit(1);
6067
}
6168

@@ -119,4 +126,4 @@ public static function log($exception)
119126
}
120127
}
121128

122-
}
129+
}

0 commit comments

Comments
 (0)