/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops($request, Exception $e) { if (config('app.debug')) { $whoops = new \Whoops\Run(); $whoops->pushHandler($request->ajax() ? new \Whoops\Handler\JsonResponseHandler() : new \Whoops\Handler\PrettyPageHandler()); $whoops->allowQuit(false); $whoops->writeToOutput(false); return response($whoops->handleException($e), $whoops->sendHttpCode()); } else { return renderHttpExceptionView($e); } }