public function generateResponseForException(RhubarbException $er) { $context = Application::current()->context(); if ($context->isXhrRequest()) { $response = new Response(); } else { $response = new HtmlResponse(); } $response->setResponseCode(Response::HTTP_STATUS_SERVER_ERROR_GENERIC); $response->setContent($er->getPublicMessage()); return $response; }