mchades commented on code in PR #14040:
URL: https://github.com/apache/gravitino/pull/14040#discussion_r4335360762


##########
core/src/main/java/org/apache/gravitino/policy/PolicyManager.java:
##########
@@ -161,10 +162,14 @@ public PolicyEntity alterPolicy(String metalake, String 
policyName, PolicyChange
       throw new NoSuchPolicyException(
           "Policy with name %s under metalake %s does not exist", policyName, 
metalake);
     } catch (EntityAlreadyExistsException e) {
-      throw new RuntimeException(
-          String.format(
-              "Trying to alter policy %s under metalake %s, but the new name 
already exists",
-              policyName, metalake));
+      String newName =
+          Arrays.stream(changes)
+              .filter(c -> c instanceof PolicyChange.RenamePolicy)
+              .map(c -> ((PolicyChange.RenamePolicy) c).getNewName())
+              .reduce((first, second) -> second)
+              .orElse(policyName);
+      throw new PolicyAlreadyExistsException(
+          e, "Policy with name %s under metalake %s already exists", newName, 
metalake);

Review Comment:
   Added HTTP 409 responses to `alterPolicy` and `updateModel`, reusing the 
existing `AlreadyExistsException` examples. `./gradlew :docs:build` passes.



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