private StartStreamTranscriptionResponseHandler getResponseHandler()

in functions/source/amazon-chime-recordandtranscribe/src/main/java/com/amazonaws/kvstranscribestreaming/transcribe/TranscribeStreamingRetryClient.java [193:217]


    private StartStreamTranscriptionResponseHandler getResponseHandler(
            StreamTranscriptionBehavior transcriptionBehavior) {
        final StartStreamTranscriptionResponseHandler build = StartStreamTranscriptionResponseHandler.builder()
                .onResponse(r -> {
                    transcriptionBehavior.onResponse(r);
                })
                .onError(e -> {
                    //Do nothing here. Don't close any streams that shouldn't be cleaned up yet.
                })
                .onComplete(() -> {
                    //Do nothing here. Don't close any streams that shouldn't be cleaned up yet.
                })
                .subscriber(event -> {
                    try {
                        transcriptionBehavior.onStream(event);
                    }
                    // We swallow any exception occurred while processing the TranscriptEvent and continue transcribing
                    // Transcribe errors will however cause the future to complete exceptionally and we'll retry (if applicable)
                    catch (Exception e) {
                        log.error("Error happened when transcribing", e);
                    }
                })
                .build();
        return build;
    }