Skip to content

Commit

Permalink
rethrow Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prwhelan committed Oct 30, 2024
1 parent d2821fe commit a352538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.xcontent.ChunkedToXContent;
Expand Down Expand Up @@ -101,6 +102,7 @@ public Flow.Publisher<? extends ChunkedToXContent> converseStream(ConverseStream
}

private void onFailure(ActionListener<?> listener, Throwable t, String method) {
ExceptionsHelper.maybeDieOnAnotherThread(t);
var unwrappedException = t;
if (t instanceof CompletionException || t instanceof ExecutionException) {
unwrappedException = t.getCause() != null ? t.getCause() : t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import software.amazon.awssdk.services.bedrockruntime.model.ConverseStreamResponseHandler;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.core.Strings;
import org.elasticsearch.logging.LogManager;
Expand Down Expand Up @@ -89,6 +90,7 @@ private void sendDownstreamOnAnotherThread(ContentBlockDeltaEvent event) {

@Override
public void onError(Throwable amazonBedrockRuntimeException) {
ExceptionsHelper.maybeDieOnAnotherThread(amazonBedrockRuntimeException);
error.set(
new ElasticsearchException(
Strings.format("AmazonBedrock StreamingChatProcessor failure: [%s]", amazonBedrockRuntimeException.getMessage()),
Expand Down

0 comments on commit a352538

Please sign in to comment.