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());
}