Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class LaravelDebugbar extends DebugBar
*/
protected $is_lumen = false;

/**
* Laravel default error handler
*
* @var callable|null
*/
protected $prevErrorHandler = null;

protected ?string $editorTemplateLink = null;
protected array $remoteServerReplacements = [];
protected bool $responseIsModified = false;
Expand Down Expand Up @@ -173,7 +180,7 @@ public function boot()

// Set custom error handler
if ($config->get('debugbar.error_handler', false)) {
set_error_handler([$this, 'handleError']);
$this->prevErrorHandler = set_error_handler([$this, 'handleError']);
}

$this->selectStorage($this);
Expand Down Expand Up @@ -645,16 +652,17 @@ public function addCollector(DataCollectorInterface $collector)
*/
public function handleError($level, $message, $file = '', $line = 0, $context = [])
{
$exception = new \ErrorException($message, 0, $level, $file, $line);
if (error_reporting() & $level) {
throw $exception;
}

$this->addThrowable($exception);
$this->addThrowable(new \ErrorException($message, 0, $level, $file, $line));
if ($this->hasCollector('messages')) {
$file = $file ? ' on ' . $this['messages']->normalizeFilePath($file) . ":{$line}" : '';
$this['messages']->addMessage($message . $file, 'deprecation');
}

if (! $this->prevErrorHandler) {
return;
}

return call_user_func($this->prevErrorHandler, $level, $message, $file, $line, $context);
}

/**
Expand Down
Loading