code: private static Response createErrorResponse(S3Exception e) {
      S3Error errorResponse = new S3Error(e.getResource(), e.getErrorCode());
      // Need to explicitly encode the string as XML because Jackson will not do it automatically.
      XmlMapper mapper = new XmlMapper();
      try {
        return Response.status(e.getErrorCode().getStatus())
            .entity(mapper.writeValueAsString(errorResponse)).build();
      } catch (JsonProcessingException e2) {
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
            .entity("Failed to encode XML: " + e2.getMessage()).build();
      }
    }
docs: Creates an error response using the given exception.
  
  @param e the exception to be converted into {@link Error} and encoded into XML
  @return the response