elliotk
230
2
Laravel

Handling Exceptions

Posted 1 year ago by elliotk

Hello,

I am trying to display a custom error page for a particular exception generated by this package: https://github.com/jrean/laravel-user-verification

It's to indicate that the current user is not verified.

I've updated the Exception Handler as follows:

    public function render($request, Exception $exception)
    {
        if ($exception instanceof UserNotVerifiedException) {
            return response()->view('errors.not-verified', [], 500);
        }
        return parent::render($request, $exception);
    }

If I dd($exception) I get the below, so I am presuming I have the syntax correct.

UserNotVerifiedException {#278 ▼
  #message: "This user is not verified."
  #code: 0
  #file: "/Users/elliot.knight/Code/cms/vendor/jrean/laravel-user-verification/src/Middleware/IsVerified.php"
  #line: 26
  trace: {▶}
}

However, no matter what I try, I get the generic exception shown.

Any help would be appreciated.

Thanks

Elliot

Please sign in or create an account to participate in this conversation.