Skip to content

Commit

Permalink
Fix new exception renderer compatibility with closure middlewares (#5…
Browse files Browse the repository at this point in the history
…1614)

In an application with a closure/inline middleware in a controller, the exception renderer fails with "Object of class Closure could not be converted to string"
  • Loading branch information
ifox authored May 29, 2024
1 parent 3334093 commit 8b769a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Illuminate/Foundation/Exceptions/Renderer/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Exceptions\Renderer;

use Closure;
use Composer\Autoload\ClassLoader;
use Illuminate\Foundation\Bootstrap\HandleExceptions;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -173,7 +174,9 @@ public function applicationRouteContext()
return $route ? array_filter([
'controller' => $route->getActionName(),
'route name' => $route->getName() ?: null,
'middleware' => implode(', ', $route->gatherMiddleware()),
'middleware' => implode(', ', array_map(function ($middleware) {
return $middleware instanceof Closure ? 'Closure' : $middleware;
}, $route->gatherMiddleware())),
]) : [];
}

Expand Down

0 comments on commit 8b769a0

Please sign in to comment.