jerryshao commented on code in PR #14772:
URL: https://github.com/apache/gravitino/pull/14772#discussion_r4534485593
##########
clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java:
##########
@@ -1094,6 +1107,34 @@ public void accept(ErrorResponse errorResponse) {
}
}
+ /** Error handler specific to domain operations. */
+ private static class DomainErrorHandler extends TagErrorHandler {
+ private static final DomainErrorHandler INSTANCE = new
DomainErrorHandler();
+
+ @Override
+ public void accept(ErrorResponse response) {
+ String message = formatErrorMessage(response);
+ if (response.getCode() == ErrorConstants.NOT_FOUND_CODE
+ &&
response.getType().equals(NoSuchDomainException.class.getSimpleName())) {
+ throw new NoSuchDomainException("%s", message);
+ }
+ if (response.getCode() == ErrorConstants.ALREADY_EXISTS_CODE) {
+ if
(response.getType().equals(DomainAlreadyExistsException.class.getSimpleName()))
{
+ throw new DomainAlreadyExistsException("%s", message);
+ }
+ if
(response.getType().equals(BackingTagAlreadyBoundException.class.getSimpleName()))
{
+ throw new BackingTagAlreadyBoundException("%s", message);
+ }
+ }
+ if ((response.getCode() == ErrorConstants.UNSUPPORTED_OPERATION_CODE
+ || response.getCode() == ErrorConstants.NON_EMPTY_CODE)
+ &&
response.getType().equals(NonEmptyDomainException.class.getSimpleName())) {
+ throw new NonEmptyDomainException("%s", message);
+ }
+ super.accept(response);
Review Comment:
Thanks for catching this, @mchades. Fixed in ac4c1f21a8. Both
`listDomains()` and `listDomainsInfo()` now preserve
`NoSuchMetadataObjectException` when the server returns a 404 for a deleted
leaf. I added regression coverage for both methods in `TestSupportsDomains` and
verified that both assertions failed before the fix and passed afterward. Could
you take another look?
--
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]