isHttpException($e)) { return $this->renderHttpException($e); } if (config('app.debug')) { return $this->renderExceptionWithWhoops($e); } return parent::render($request, $e); } /** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run; if(Request::ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return new \Illuminate\Http\Response( $whoops->handleException($e), $e->getStatusCode(), $e->getHeaders() ); } }