response.setResponseCode(status);
response.setContentEncoding("UTF-8");
response.setContentType("application/json");
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setStatusCode(response.getResponseCode());
errorResponse.setMessage(error.getMessage());
if (status == 500 || context.getShowErrorDetail())
errorResponse.setStackTrace(buildStackTrace(cause));
String exceptionType = error.getClass().getName();
if (!(error instanceof HyperionException))
exceptionType = InternalException.class.getName();
else
errorResponse.setErrorDetails(((HyperionException) error).getErrorDetails());
errorResponse.setType(exceptionType);
endpointMarshaller.marshall(response.getOutputStream(), errorResponse);
}
}