Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

markss's avatar

Change "Server Error" Tostated-Message in Nova

Hey there,

does anyone know how to control the error-reporting level of the toasted messages in laravel nova? When for example a database column is not available when saving a model, the toasted message will show the complete error in my local development environment, but in production it only says "Server Error". I want to disable the hidden errors to have the ability to display certain errors to the user through Exceptions.

Thanks for helping!

0 likes
1 reply
frc-itadmin's avatar

Took me a minute to track this one down because Nova uses its own exception handler - not the default App\Exceptions\Handler.. :/

To show errors in production, you'll need to override the NovaExceptionHandler in your NovaServiceProvider, like so:

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    protected function registerExceptionHandler()
    {
        $this->app->bind(ExceptionHandler::class, CustomHandler::class);
    }	
    ....

Then, inside this custom handler, you can customize the logic for showing exceptions thrown inside this exception handler. To show ALL errors thrown, you'll need to override any methods that use the config helper to get the value of 'app.debug'. (e.g. config('app.debug')) Those methods are:

  1. prepareResponse
  2. renderExceptionContent
  3. convertExceptionToArray

My implementation includes these helper methods in this new handler:

private function userIsAdmin()
{
    if ($user = \Auth::user()) {
        return $user->can('seeErrors');
    }

    return false;
}

private function shouldShowErrors()
{
    return config('app.debug') || $this->userIsAdmin();
}

Does this answer your question?

1 like

Please or to participate in this conversation.