eric-maynard commented on code in PR #402:
URL: https://github.com/apache/polaris/pull/402#discussion_r1814014854
##########
polaris-service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java:
##########
@@ -100,4 +103,27 @@ public Response toResponse(RuntimeException
runtimeException) {
LOGGER.debug("Mapped exception to errorResp: {}", errorResp);
return errorResp;
}
+
+ public static boolean isAccessDenied(String errorMsg) {
+ // Corresponding error messages for storage providers Aws/Azure/Gcp
+ // We may want to consider a change to Iceberg Core to wrap cloud provider
IO exceptions to
+ // Iceberg ForbiddenException
+ boolean isAccessDenied =
+ errorMsg != null
+ && (errorMsg.toLowerCase(Locale.ENGLISH).contains("access denied")
+ || errorMsg
+ .toLowerCase(Locale.ENGLISH)
+ .contains("this request is not authorized to perform this
operation")
+ || errorMsg.toLowerCase(Locale.ENGLISH).contains("forbidden"));
+ if (isAccessDenied) {
+ LOGGER.debug("Access Denied or Forbidden error: {}", errorMsg);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isAccessDenied(Exception e) {
+ Throwable rootCause = ExceptionUtils.getRootCause(e);
Review Comment:
In my experience it's not always correct to go for the root cause -- you may
want to check all the throwables in the cause chain
--
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]