Skip to content

Commit

Permalink
Merge pull request #87 from utopia-php/feat-allow-error-overrides
Browse files Browse the repository at this point in the history
Allow overriding the error resource from group to global hook
  • Loading branch information
eldadfux authored Jan 29, 2023
2 parents e8da557 + 784cb4f commit b8d0447
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,12 @@ public function execute(Route $route, Request $request): static
}
}
} catch (\Throwable $e) {
self::setResource('error', fn () => $e);

foreach ($groups as $group) {
foreach (self::$errors as $error) { // Group error hooks
/** @var Hook $error */
if (in_array($group, $error->getGroups())) {
self::setResource('error', fn () => $e);
try {
$arguments = $this->getArguments($error, $values, $request->getParams());
\call_user_func_array($error->getAction(), $arguments);
Expand All @@ -617,7 +618,6 @@ public function execute(Route $route, Request $request): static
foreach (self::$errors as $error) { // Global error hooks
/** @var Hook $error */
if (in_array('*', $error->getGroups())) {
self::setResource('error', fn () => $e);
try {
$arguments = $this->getArguments($error, $values, $request->getParams());
\call_user_func_array($error->getAction(), $arguments);
Expand Down

0 comments on commit b8d0447

Please sign in to comment.