Skip to content

Commit

Permalink
fix: patch up issue with custom error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Jul 8, 2023
1 parent 976305b commit 8964d19
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,24 @@ protected function setupErrorHandler()
{
$this->errorHandler = (new \Leaf\Exception\Run());
$this->errorHandler->register();

error_reporting((bool) $this->config('debug') ? E_ALL : 0);
ini_set('display_errors', (bool) $this->config('debug') ? '1' : '0');
}

/**
* Set a custom error screen.
* @param callable|array $handler The function to be executed
* @param $handler The function to be executed
*/
public function setErrorHandler($handler, bool $wrapper = true)
public function setErrorHandler($handler)
{
if (Anchor::toBool($this->config('debug')) === false) {
if ($this->errorHandler instanceof \Leaf\Exception\Run) {
$this->errorHandler->unregister();
}


$this->errorHandler = new \Leaf\Exception\Run();

if ($handler instanceof \Leaf\Exception\Handler\Handler) {
$this->errorHandler->pushHandler($handler)->register();
} else {
$this
->errorHandler
->pushHandler(new \Leaf\Exception\Handler\CustomHandler($handler))
->register();
}
$this
->errorHandler
->pushHandler($handler)
->register();
}
}

Expand Down

0 comments on commit 8964d19

Please sign in to comment.