eric-maynard commented on code in PR #1181:
URL: https://github.com/apache/polaris/pull/1181#discussion_r2040068642


##########
service/common/src/main/java/org/apache/polaris/service/exception/IcebergPersistenceExceptionMapper.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.polaris.service.exception;
+
+import jakarta.persistence.PersistenceException;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.ext.ExceptionMapper;
+import jakarta.ws.rs.ext.Provider;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+
+@Provider
+public class IcebergPersistenceExceptionMapper
+    implements ExceptionMapper<PersistenceException> {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(IcebergPersistenceExceptionMapper.class);
+
+  @Override
+  public Response toResponse(PersistenceException exception) {
+    LOGGER.info("Full PersistenceException", exception);
+
+    ErrorResponse icebergErrorResponse =
+        ErrorResponse.builder()
+            
.responseCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
+            .withType(exception.getClass().getSimpleName())

Review Comment:
   Well, it's better than nothing... ideally, these exceptions should be caught 
and wrapped within the business logic before making it back to the client. They 
would be wrapped with something that the IcebergExceptionMapper or 
PolarisExceptionMapper can map to a client-friendly response. However in the 
event that we miss the wrapping, I can see how this additional mapper is useful.



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

Reply via email to