improve error class comments.
This commit is contained in:
parent
26ff78da84
commit
ee307657d3
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
You have successfully installed Laravel.
|
You have successfully installed Laravel.
|
||||||
|
<?php Cache::driver('adslkadsl'); ?>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
Perhaps you would like to <a href="http://laravel.com/docs">peruse the documentation</a> or <a href="http://github.com/taylorotwell/laravel">contribute on GitHub</a>?
|
Perhaps you would like to <a href="http://laravel.com/docs">peruse the documentation</a> or <a href="http://github.com/taylorotwell/laravel">contribute on GitHub</a>?
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Error {
|
class Error {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error levels.
|
* Error levels and descriptions.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,8 @@ class Error {
|
||||||
public static function handle($e)
|
public static function handle($e)
|
||||||
{
|
{
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Clean the output buffer.
|
// Clean the output buffer. We don't want any rendered
|
||||||
|
// views or text to be sent to the browser.
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
if (ob_get_level() > 0)
|
if (ob_get_level() > 0)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,7 @@ public static function handle($e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Get the error severity.
|
// Get the error severity in human readable format.
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
$severity = (array_key_exists($e->getCode(), static::$levels)) ? static::$levels[$e->getCode()] : $e->getCode();
|
$severity = (array_key_exists($e->getCode(), static::$levels)) ? static::$levels[$e->getCode()] : $e->getCode();
|
||||||
|
|
||||||
|
@ -57,19 +58,21 @@ public static function handle($e)
|
||||||
$file = $e->getFile();
|
$file = $e->getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------
|
|
||||||
// Trim the period off of the error message.
|
|
||||||
// -----------------------------------------------------
|
|
||||||
$message = rtrim($e->getMessage(), '.');
|
$message = rtrim($e->getMessage(), '.');
|
||||||
|
|
||||||
// -----------------------------------------------------
|
|
||||||
// Log the error.
|
|
||||||
// -----------------------------------------------------
|
|
||||||
if (Config::get('error.log'))
|
if (Config::get('error.log'))
|
||||||
{
|
{
|
||||||
Log::error($message.' in '.$e->getFile().' on line '.$e->getLine());
|
Log::error($message.' in '.$e->getFile().' on line '.$e->getLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------
|
||||||
|
// Detailed error view contains the file name and stack
|
||||||
|
// trace of the error. It is not wise to have details
|
||||||
|
// enabled in a production environment.
|
||||||
|
//
|
||||||
|
// The generic error view (error/500) only has a simple,
|
||||||
|
// generic error message suitable for production.
|
||||||
|
// -----------------------------------------------------
|
||||||
if (Config::get('error.detail'))
|
if (Config::get('error.detail'))
|
||||||
{
|
{
|
||||||
$view = View::make('exception')
|
$view = View::make('exception')
|
||||||
|
@ -107,24 +110,16 @@ private static function context($path, $line, $padding = 5)
|
||||||
array_unshift($file, '');
|
array_unshift($file, '');
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Calculate the starting position.
|
// Calculate the starting position of the file context.
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
$start = $line - $padding;
|
$start = $line - $padding;
|
||||||
|
$start = ($start < 0) ? 0 : $start;
|
||||||
if ($start < 0)
|
|
||||||
{
|
|
||||||
$start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Calculate the context length.
|
// Calculate the context length.
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
$length = ($line - $start) + $padding + 1;
|
$length = ($line - $start) + $padding + 1;
|
||||||
|
$length = (($start + $length) > count($file) - 1) ? null : $length;
|
||||||
if (($start + $length) > count($file) - 1)
|
|
||||||
{
|
|
||||||
$length = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_slice($file, $start, $length, true);
|
return array_slice($file, $start, $length, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue