kbendick commented on a change in pull request #4097:
URL: https://github.com/apache/iceberg/pull/4097#discussion_r805031055



##########
File path: 
core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.rest.responses;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Standard response body on error.
+ */
+public class ErrorResponse {
+
+  private final String message;
+  private final String type;
+  private final Integer code;
+
+  // These aren't part of the spec, but they are likely needed when we 
abstract out the current HTTP client.
+  @JsonIgnore
+  private final String body;
+  @JsonIgnore
+  private Map<String, String> headers;
+
+  private ErrorResponse(String message, String type, Integer code) {
+    this(message, type, code, null, Collections.emptyMap());
+  }
+
+  private ErrorResponse(String message, String type, Integer code, String 
body, Map<String, String> headers) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    this.body = body;
+    this.headers = headers;
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public String message() {
+    return message;
+  }
+
+  public String type() {
+    return type;
+  }
+
+  public Integer code() {
+    return code;
+  }
+
+  public String body() {
+    return body;
+  }

Review comment:
       This is the raw response body. It's not part of the current `ErrorModel` 
definition, but I think having it in case the response that returns an error 
isn't a proper `ErrorResponse`.
   
   For example, if a request timesout before ever hitting the server, it can 
return `text/plain` in which case having the body would be useful.
   
   I'd likely consider moving the raw body and the headers to a 
`ResponseContext` object so that they can be grabbed from the response type 
pulled from the implementation.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to