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 and amorton committed Jul 10, 2024
1 parent 33311d2 commit bd6be18
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 bd6be18

Please sign in to comment.