renderExceptionWithWhoops($exc); } if ($exc instanceof ModelNotFoundException) { $exc = new NotFoundHttpException($exc->getMessage(), $exc); } if ($exc instanceof TokenMismatchException) { return redirect()->back() ->withInput($request->except('password', '_token')) ->withErrors('Validation Token has expired. Please try again', 'csrf'); } return parent::render($request, $exc); } /** * Render an exception using Whoops. * * @param \Exception $exc * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $exc) { $whoops = new \Whoops\Run; $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor(function ($file, $line) { return "atom://open?file=$file&line=$line"; }); $whoops->pushHandler($handler); return new \Illuminate\Http\Response( $whoops->handleException($exc), $exc->getStatusCode(), $exc->getHeaders() ); } }