Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable #51730

Closed
TerrePorter opened this issue Jun 6, 2024 · 2 comments
Closed

Comments

@TerrePorter
Copy link

Laravel Version

11.9.2

PHP Version

8.3.1

Database Driver & Version

8.0.35-0ubuntu0.22.04.1 in homestead

Description

I am using Laravel 11.9.2 and nwidart/laravel-modules version 11.0.1.

With the change to how exceptions are handled, ie…

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        // api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        //
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();

My module custom error handler code is no longer functioning.

Steps To Reproduce

I’ve attempted to return to the old style that had a error handler class as each of my modules handle their own errors and I don’t want to have all the error code in the base code but contained in the module.

Here is how I have done this.

In my AppServiceProvider I have added this to the register function

use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
 {
$this->app->singleton(ExceptionHandlerContract::class, Handler::class);
}
}

And commented out the withExceptions on the app.php file. The base handler has the code to load the module error handler code.

This works in the browser and my module exceptions are running, but when using console commands I get an error message,

[Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.

Any clues on how to fix this?

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@crynobone crynobone reopened this Jun 10, 2024
@TerrePorter
Copy link
Author

TerrePorter commented Jun 10, 2024

@crynobone I created the bug report project on my local dev, but the error did not happen as it did in my original project. Upon review, I noticed that the version of laravel being used on the bug project was v11.10.0, and on my original project is v11.9.2. I updated my original project and it appears the version update to v11.10.0 has fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants