protected function defaultError($e = null)
{
if ($e instanceof Exception) {
$errorEnvelope = $this->getErrorEnvelope();
if ($e instanceof ApiErrorException) {
$errorEnvelope->errors[] = new ErrorMessage($e->getError(), $e->getMessage());
$this->response->setStatus($e->getStatus());
} else {
if (!$e instanceof ErrorException) {
\Scalr::logException($e);
$errorEnvelope->errors[] = new ErrorMessage(ErrorMessage::ERR_INTERNAL_SERVER_ERROR, "Server Error");
$this->response->setStatus(500);
}
}
$this->response->setContentType("application/json", "utf-8");
return @json_encode($errorEnvelope);
}
return '';
}