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



##########
File path: 
core/src/main/java/org/apache/iceberg/rest/http/IcebergHttpResponse.java
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.http;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * All responses for the first version of the Iceberg REST API will be JSON 
objects, a top-level envelope object with two fields,
+ * `error` and `data`, which are themselves JSON objects.
+ *
+ * data: represents the JSON encoded response for a successful path or for a 
valid / expected failure. JSON representation of various response types
+ * error: a standardized obect on error, containing the error code, message, 
type, and  additional metadata (an optional JSON object of metadata) as defined 
below.
+ *
+ * All responses for the REST catalog should be wrapped this way, vs using 
primitives. For example, for a ListTableResponse, listing tables under a 
namespace "accounting",
+ * we'd get a JSON object back like the following:
+ *
+ * { "data": { "identifiers": [ "accounting.tax", 
"accounting.currency_conversions"] }, "error", {} }
+ *
+ * If the namesapce `accounting` didn't request, the response from that call 
would have a body like the following,
+ * where the `code` 40401 is a two-part identifier:
+ *    - HTTP response code: 404
+ *    - Two digit internal application defined error code for further detail: 
01 - Namespace not found.
+ *
+ * { "data": {}, "error": { "message": "Failed to list tables. The Namespace 
'accounting' does not exist", "type": "NamespaceNotFoundException", "code": 
40401 }
+ *
+ * We could also embed the HTTP response code plainly by itself, without 
internally documented codes, as a separate field. I have found having a 
documented list of internal
+ * error codes to be very helpful previously, but am open to discussion on 
this.

Review comment:
       So since we have `type`, which can be used to enumerate all of the 
possible sub fields, we've moved in the direction of just using the 3-digit 
HTTP response code in the body.
   
   This file isn't part of the spec at all, as mentioned below,  so I forgot to 
update it. I will remove it eventually but leave it so we can discuss.
   
   Do you have input on using a dedicated int `code` (perhaps not constrained 
to HTTP code space as you mentioned) instead of just using the standardized 
value in `type` (which is a string)?
   
   If we used `code`, the lookup table in my experience brings you to `type`. 
But I have previously used the way you described, with numeric error codes that 
we define a lookup table for that are independent. Do you have feedback on 
moving to just `type`?




-- 
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