Skip to content

Commit

Permalink
add ability to override the default error view paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedabdel3al committed May 5, 2024
1 parent 8c684a2 commit bbccebb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/Foundation/Configuration/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public function report(callable $using)
return $this->handler->reportable($using);
}

/**
* Register error view paths callback.
*
* @param callable $using
* @return void
*/
public function registerErrorViewPathsUsing(callable $using)
{
$this->handler->registerErrorViewPathsUsing($using);
}

/**
* Register a reportable callback.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class Handler implements ExceptionHandlerContract
*/
protected $finalizeResponseCallback;

/**
* The callback that should be used to register the application's error view paths.
*
* @var callable|null
*/
protected $registerErrorViewPathsUsing;

/**
* The registered exception mappings.
*
Expand Down Expand Up @@ -233,6 +240,17 @@ public function renderable(callable $renderUsing)
return $this;
}

/**
* Register error view paths callback.
*
* @param callable $using
* @return void
*/
public function registerErrorViewPathsUsing(callable $using)
{
$this->registerErrorViewPathsUsing = $using;
}

/**
* Register a new exception mapping.
*
Expand Down Expand Up @@ -897,6 +915,11 @@ protected function renderHttpException(HttpExceptionInterface $e)
*/
protected function registerErrorViewPaths()
{
if (! is_null($this->registerErrorViewPathsUsing)) {
call_user_func($this->registerErrorViewPathsUsing);

return;
}
(new RegisterErrorViewPaths)();
}

Expand Down

0 comments on commit bbccebb

Please sign in to comment.