io.contek.zeus.client.errors.GatewayClientErrors Maven / Gradle / Ivy
package io.contek.zeus.client.errors;
import io.grpc.StatusRuntimeException;
import javax.annotation.concurrent.Immutable;
@Immutable
public final class GatewayClientErrors {
public static GatewayClientException toClientException(Throwable t) {
if (t instanceof StatusRuntimeException casted) {
return toClientException(casted);
}
throw new GatewayUnknownException(t);
}
private static GatewayClientException toClientException(StatusRuntimeException error) {
return switch (error.getStatus().getCode()) {
case UNAVAILABLE, CANCELLED -> new GatewayUnavailableException(error);
case RESOURCE_EXHAUSTED -> new GatewayRateLimitException(error);
case INTERNAL -> new GatewayInternalException(error);
default -> throw new GatewayUnknownException(error);
};
}
private GatewayClientErrors() {}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy