in clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java [441:499]
public void accept(ErrorResponse errorResponse) {
String errorMessage = formatErrorMessage(errorResponse);
switch (errorResponse.getCode()) {
case ErrorConstants.ILLEGAL_ARGUMENTS_CODE:
throw new IllegalArgumentException(errorMessage);
case ErrorConstants.CONNECTION_FAILED_CODE:
throw new ConnectionFailedException(errorMessage);
case ErrorConstants.NOT_FOUND_CODE:
if (errorResponse.getType().equals(NoSuchMetalakeException.class.getSimpleName())) {
throw new NoSuchMetalakeException(errorMessage);
} else if (errorResponse.getType().equals(NoSuchCatalogException.class.getSimpleName())) {
throw new NoSuchCatalogException(errorMessage);
} else {
throw new NotFoundException(errorMessage);
}
case ErrorConstants.ALREADY_EXISTS_CODE:
throw new CatalogAlreadyExistsException(errorMessage);
case ErrorConstants.FORBIDDEN_CODE:
throw new ForbiddenException(errorMessage);
case ErrorConstants.INTERNAL_ERROR_CODE:
throw new RuntimeException(errorMessage);
case ErrorConstants.IN_USE_CODE:
if (errorResponse.getType().equals(CatalogInUseException.class.getSimpleName())) {
throw new CatalogInUseException(errorMessage);
} else if (errorResponse.getType().equals(MetalakeInUseException.class.getSimpleName())) {
throw new MetalakeInUseException(errorMessage);
} else {
throw new InUseException(errorMessage);
}
case ErrorConstants.NOT_IN_USE_CODE:
if (errorResponse.getType().equals(CatalogNotInUseException.class.getSimpleName())) {
throw new CatalogNotInUseException(errorMessage);
} else if (errorResponse
.getType()
.equals(MetalakeNotInUseException.class.getSimpleName())) {
throw new MetalakeNotInUseException(errorMessage);
} else {
throw new NotInUseException(errorMessage);
}
case ErrorConstants.NON_EMPTY_CODE:
throw new NonEmptyCatalogException(errorMessage);
default:
super.accept(errorResponse);
}
}