Skip to content

Commit 8e48c55

Browse files
committed
Change back to switch
1 parent dfb4992 commit 8e48c55

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

service/common/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.polaris.core.entity.PolarisEntityType;
3232
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
3333
import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper;
34-
import org.apache.polaris.core.persistence.dao.entity.BaseResult;
3534
import org.apache.polaris.core.persistence.dao.entity.DropEntityResult;
3635
import org.apache.polaris.core.persistence.dao.entity.EntityResult;
3736
import org.apache.polaris.core.persistence.resolver.PolarisResolutionManifestCatalogView;
@@ -115,13 +114,15 @@ public Policy createPolicy(
115114

116115
if (!res.isSuccess()) {
117116

118-
if (res.getReturnStatus() == BaseResult.ReturnStatus.ENTITY_ALREADY_EXISTS) {
119-
throw new AlreadyExistsException("Policy already exists %s", policyIdentifier);
120-
} else {
121-
throw new IllegalStateException(
122-
String.format(
123-
"Unknown error status for identifier %s: %s with extraInfo: %s",
124-
policyIdentifier, res.getReturnStatus(), res.getExtraInformation()));
117+
switch (res.getReturnStatus()) {
118+
case ENTITY_ALREADY_EXISTS:
119+
throw new AlreadyExistsException("Policy already exists %s", policyIdentifier);
120+
121+
default:
122+
throw new IllegalStateException(
123+
String.format(
124+
"Unknown error status for identifier %s: %s with extraInfo: %s",
125+
policyIdentifier, res.getReturnStatus(), res.getExtraInformation()));
125126
}
126127
}
127128

0 commit comments

Comments
 (0)