dimas-b commented on code in PR #1989:
URL: https://github.com/apache/polaris/pull/1989#discussion_r2222871272


##########
service/common/src/main/java/org/apache/polaris/service/exception/PolarisExceptionMapper.java:
##########
@@ -45,23 +46,19 @@ public class PolarisExceptionMapper implements 
ExceptionMapper<PolarisException>
   private static final Logger LOGGER = 
LoggerFactory.getLogger(PolarisExceptionMapper.class);
 
   private Response.Status getStatus(PolarisException exception) {
-    if (exception instanceof AlreadyExistsException) {
-      return Response.Status.CONFLICT;
-    } else if (exception instanceof InvalidPolicyException) {
-      return Response.Status.BAD_REQUEST;
-    } else if (exception instanceof PolicyAttachException) {
-      return Response.Status.BAD_REQUEST;
-    } else if (exception instanceof NoSuchPolicyException) {
-      return Response.Status.NOT_FOUND;
-    } else if (exception instanceof PolicyVersionMismatchException) {
-      return Response.Status.CONFLICT;
-    } else if (exception instanceof PolicyMappingAlreadyExistsException) {
-      return Response.Status.CONFLICT;
-    } else if (exception instanceof PolicyInUseException) {
-      return Response.Status.BAD_REQUEST;
-    } else {
-      return Response.Status.INTERNAL_SERVER_ERROR;
-    }
+    return switch (exception) {
+      case AlreadyExistsException alreadyExistsException -> 
Response.Status.CONFLICT;
+      case CommitConflictException commitConflictException -> 
Response.Status.REQUEST_TIMEOUT;

Review Comment:
   I believe 408 does not match this use case. Per PRC 
[9110](https://httpwg.org/specs/rfc9110.html#status.408): `The 408 (Request 
Timeout) status code indicates that the server did not receive a complete 
request message within the time that it was prepared to wait.`



-- 
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: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to