Closed
Description
- Laravel Version: 6.20.15 / 8.25.0 / 9.x (8076d86)
- PHP Version: N/A
- Database Driver & Version: N/A
Description:
The ViewException
class introduced in #36032 does not pass dependencies to the wrapped exception's report
method. This causes a fatal error when an exception thrown in a view has a dependency
See the docs:
You may type-hint any required dependencies of the report method and they will automatically be injected into the method by Laravel's service container.
https://laravel.com/docs/8.x/errors#renderable-exceptions
Steps To Reproduce:
- Create a new Laravel project
- Remove Ignition & Collision (
composer remove facade/ignition nunomaduro/collision
) [6.x & 8.x only] - Create a custom exception class with a
report
method that requires dependencies, e.g.:namespace App\Exceptions; class MyException extends \Exception { public function report(\Illuminate\Contracts\Auth\Guard $guard) { return false; } }
- Throw an instance of this exception in a view
- An
ArgumentCountError
is thrown:Too few arguments to function App\Exceptions\MyException::report()