/** * Handle an error - set the resulting error document to the response object * @param \Exception $e * @param integer $defaultResponseCode the default response code to use if no match on exception type occurs * @param ResponseInterface $errorDocument * @return ResultSet the error result set */ public function handleError(\Exception $e, $defaultResponseCode = 500, ResponseInterface $errorDocument = null) { if (is_null($errorDocument)) { $errorDocument = $this->representation->getDefaultErrorResponse(); } $this->error_handler->error($e, $defaultResponseCode, $errorDocument); $this->getResponse()->setStatusCode($this->error_handler->getResponseCode()); $this->getResponse()->setHttpHeader('Content-Type', $errorDocument::getContentType()); $this->getResponse()->setBody($errorDocument->render()); }