app/Exceptions/Handler.php
/**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
Render an exception into an HTTP response.
Render an exception into an HTTP response .
public function render($request, Exception $exception)
    {
        if ($exception instanceof UnauthorizedHttpException) {
            $preException = $exception->getPrevious();
            if ($preException instanceof
                        \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
                return response()->json(['error' => 'token_expired'], 400);
            } elseif ($preException instanceof
                        \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
                return response()->json(['error' => 'TOKEN_INVALID'], 400);
            } elseif ($preException instanceof
                    \Tymon\JWTAuth\Exceptions\TokenBlacklistedException) {
                return response()->json(['error' => 'TOKEN_BLACKLISTED'], 400);
            }
            if ($exception->getMessage() === 'Token not provided') {
                return response()->json(['error' => 'Token not provided'], 400);
            }
        }
        return parent::render($request, $exception);
    }
public function render ( $ request , Exception $ exception ) { if ( $ exception instanceof UnauthorizedHttpException ) { $ preException = $ exception -> getPrevious ( ) ; if ( $ preException instanceof \ Tymon \ JWTAuth \ Exceptions \ TokenExpiredException ) { return response ( ) -> json ( [ 'error' => 'token_expired' ] , 400 ) ; } elseif ( $ preException instanceof \ Tymon \ JWTAuth \ Exceptions \ TokenInvalidException ) { return response ( ) -> json ( [ 'error' => 'TOKEN_INVALID' ] , 400 ) ; } elseif ( $ preException instanceof \ Tymon \ JWTAuth \ Exceptions \ TokenBlacklistedException ) { return response ( ) -> json ( [ 'error' => 'TOKEN_BLACKLISTED' ] , 400 ) ; } if ( $ exception -> getMessage ( ) === 'Token not provided' ) { return response ( ) -> json ( [ 'error' => 'Token not provided' ] , 400 ) ; } } return parent :: render ( $ request , $ exception ) ; }
Render an exception into an HTTP response.
Render an exception into an HTTP response .