match($request); } return parent::render($request, $exception); } /** * Convert an authentication exception into an unauthenticated response. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest('login'); } /** * Render an exception using Whoops. * * @param \Exception $exc * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $exception) { $whoops = new \Whoops\Run; $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor(function ($file, $line) { return "atom://open?file=$file&line=$line"; }); $whoops->pushHandler($handler); $flattened = FlattenException::create($exception); return new \Illuminate\Http\Response( $whoops->handleException($exc), $flattened->getStatusCode(), $flattened->getHeaders() ); } }