1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 13:28:35 +01:00

Check if the exception file exists.

Can be null/empty sometimes? Not really sure, but see https://github.com/barryvdh/laravel-debugbar/issues/135
This commit is contained in:
Barry vd. Heuvel 2014-05-05 09:35:28 +02:00
parent ab02c692d2
commit 849231ddab

View File

@ -69,15 +69,20 @@ class ExceptionsCollector extends DataCollector implements Renderable
*/
public function formatExceptionData(Exception $e)
{
$lines = file($e->getFile());
$start = $e->getLine() - 4;
$lines = array_slice($lines, $start < 0 ? 0 : $start, 7);
$filePath = $e->getFile();
if ($filePath && file_exists($filePath)) {
$lines = file($filePath);
$start = $e->getLine() - 4;
$lines = array_slice($lines, $start < 0 ? 0 : $start, 7);
} else {
$lines = array("Cannot open the file ($filePath) in which the exception occurred ");
}
return array(
'type' => get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile(),
'file' => $filePath,
'line' => $e->getLine(),
'surrounding_lines' => $lines
);