Skip to content

Commit

Permalink
Improve error message when EGW timeout (#1255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazel-Datastax authored Jul 10, 2024
1 parent 197bfd2 commit 9d977cd
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.stargate.sgv2.jsonapi.service.embedding.gateway;

import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.smallrye.mutiny.Uni;
import io.stargate.embedding.gateway.EmbeddingGateway;
import io.stargate.embedding.gateway.EmbeddingService;
Expand Down Expand Up @@ -147,9 +149,15 @@ else if (value instanceof Boolean)
.setEmbeddingRequest(embeddingRequest)
.setProviderContext(providerContext)
.build();

final Uni<EmbeddingGateway.EmbeddingResponse> embeddingResponse =
embeddingService.embed(providerEmbedRequest);
Uni<EmbeddingGateway.EmbeddingResponse> embeddingResponse;
try {
embeddingResponse = embeddingService.embed(providerEmbedRequest);
} catch (StatusRuntimeException e) {
if (e.getStatus().getCode().equals(Status.Code.DEADLINE_EXCEEDED)) {
throw ErrorCode.EMBEDDING_PROVIDER_TIMEOUT.toApiException(e, e.getMessage());
}
throw e;
}
return embeddingResponse
.onItem()
.transform(
Expand Down

0 comments on commit 9d977cd

Please sign in to comment.