public static <T> Response call(RestUtils.RestCallable<T> callable,
      AlluxioConfiguration alluxioConf, @Nullable Map<String, Object> headers) {
    try {
      // TODO(cc): reconsider how to enable authentication
      if (SecurityUtils.isSecurityEnabled(alluxioConf)
          && AuthenticatedClientUser.get(alluxioConf) == null) {
        AuthenticatedClientUser.set(ServerUserState.global().getUser().getName());
      }
    } catch (IOException e) {
      LOG.warn("Failed to set AuthenticatedClientUser in REST service handler: {}", e.toString());
      return createErrorResponse(e, alluxioConf);
    }

    try {
      return createResponse(callable.call(), alluxioConf, headers);
    } catch (Exception e) {
      LOG.warn("Unexpected error invoking rest endpoint: {}", e.toString());
      return createErrorResponse(e, alluxioConf);
    }
  }
@Test
  public void errorResponse() throws Exception {
    final Status status = Status.ALREADY_EXISTS;
    final String message = "error message";
    Response response = RestUtils.call(new RestUtils.RestCallable<Void>() {
      @Override
      public Void call() throws Exception {
        throw new AlluxioStatusException(status.withDescription(message));
      }
    }, Configuration.global());
    Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
        response.getStatus());
    RestUtils.ErrorResponse errorResponse = (RestUtils.ErrorResponse) response.getEntity();
    Assert.assertEquals(status.getCode(), errorResponse.getStatusCode());
    Assert.assertEquals(message, errorResponse.getMessage());
  }