request = $request; } /** * Get the error response associated with the given exception. * * @param \Exception $exception * @param int $code * @param string[] $headers * * @return \Symfony\Component\HttpFoundation\Response */ public function display(Exception $exception, $code, array $headers) { return redirect()->guest('auth/login'); } /** * Get the supported content type. * * @return string */ public function contentType() { return 'text/html'; } /** * Can we display the exception? * * @param \Exception $exception * * @return bool */ public function canDisplay(Exception $exception) { $redirect = $exception instanceof HttpExceptionInterface && $exception->getStatusCode() === 401; return $redirect && !$this->request->is('api*'); } /** * Do we provide verbose information about the exception? * * @return bool */ public function isVerbose() { return false; } }