Improve view errors.

This commit is contained in:
Taylor Otwell
2012-09-26 16:20:56 -04:00
parent 633c2bde83
commit b043482905
2 changed files with 23 additions and 2 deletions

View File

@@ -15,6 +15,18 @@ class Error {
ob_get_level() and ob_end_clean();
$message = $exception->getMessage();
// For Laravel view errors we want to show a prettier error:
$file = $exception->getFile();
if (str_contains($exception->getFile(), 'eval()') and str_contains($exception->getFile(), 'laravel/view.php'))
{
$message = 'Error rendering view: ['.View::$last['name'].']'.PHP_EOL.PHP_EOL.$message;
$file = View::$last['path'];
}
// If detailed errors are enabled, we'll just format the exception into
// a simple error message and display it on the screen. We don't use a
// View in case the problem is in the View class.
@@ -22,9 +34,9 @@ class Error {
{
echo "<html><h2>Unhandled Exception</h2>
<h3>Message:</h3>
<pre>".$exception->getMessage()."</pre>
<pre>".$message."</pre>
<h3>Location:</h3>
<pre>".$exception->getFile()." on line ".$exception->getLine()."</pre>";
<pre>".$file." on line ".$exception->getLine()."</pre>";
if ($trace)
{