mchades commented on code in PR #14772:
URL: https://github.com/apache/gravitino/pull/14772#discussion_r4534286407
##########
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:
When a previously loaded leaf is deleted, the reverse lookup returns HTTP
404 with `type=NoSuchMetadataObjectException`. I reproduced `listDomains()`
throwing the generic `NotFoundException` at this fallback, so callers catching
`NoSuchMetadataObjectException` miss the error. Please preserve the server
exception type here and cover both lookup methods in `TestSupportsDomains`.
--
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]