The error reporting documentation is incorrect (see https://nova.laravel.com/docs/4.0/installation.html#error-reporting). Any custom exception handler which is being registered using Nova::report() is being discarded after the NovaExceptionHandler is registered by the NovaApplicationServiceProvider::registerExceptionHandler() method. The 'NovaExceptionHandler::register()' method is executed twice (firstly while binding, secondly when an exception occurs) and the Nova::$reportCallback is not available anymore on second register execution.
Detailed steps to reproduce the issue on a fresh Nova installation:
Add method to NovaServiceProvider as documentation states:
public function register(): void
{
Nova::report(fn ($exception) => dd('I am invisible'));
}
Trigger exception by adding undefined function to any resource:
public function fields(NovaRequest $request): array
{
nova_exception_test();
}
Open your Nova admin
You will see the default error handler but instead you would expect to see the debug I am invisible.
Workaround
The workaround for this issue is to register the handler as a singleton in the NovaServiceProvider:
protected function registerExceptionHandler()
{
app()->singleton(ExceptionHandler::class, NovaExceptionHandler::class);
}
Description:
The error reporting documentation is incorrect (see https://nova.laravel.com/docs/4.0/installation.html#error-reporting). Any custom exception handler which is being registered using
Nova::report()
is being discarded after theNovaExceptionHandler
is registered by theNovaApplicationServiceProvider::registerExceptionHandler()
method. The 'NovaExceptionHandler::register()' method is executed twice (firstly while binding, secondly when an exception occurs) and theNova::$reportCallback
is not available anymore on second register execution.Detailed steps to reproduce the issue on a fresh Nova installation:
NovaServiceProvider
as documentation states:You will see the default error handler but instead you would expect to see the debug
I am invisible
.Workaround
The workaround for this issue is to register the handler as a singleton in the
NovaServiceProvider
: