Skip to content

Commit

Permalink
OnResultFunc でエラーになった場合も JSON を返す
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Jan 19, 2024
1 parent 8c53f61 commit c3bf4d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions amazon_transcribe_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader)
case *transcribestreamingservice.TranscriptEvent:
if h.OnResultFunc != nil {
if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, e.Transcript.Results); err != nil {
errResponse := NewSuzuErrorResponse(err.Error())
if err := encoder.Encode(errResponse); err != nil {

Check failure on line 107 in amazon_transcribe_handler.go

View workflow job for this annotation

GitHub Actions / ci

empty branch (SA9003)
// TODO: ログを書く
}
w.CloseWithError(err)
return
}
Expand Down
4 changes: 4 additions & 0 deletions speech_to_text_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (h *SpeechToTextHandler) Handle(ctx context.Context, reader io.Reader) (*io

if h.OnResultFunc != nil {
if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, resp.Results); err != nil {
errResponse := NewSuzuErrorResponse(err.Error())
if err := encoder.Encode(errResponse); err != nil {

Check failure on line 148 in speech_to_text_handler.go

View workflow job for this annotation

GitHub Actions / ci

empty branch (SA9003)
// TODO: ログを書く
}
w.CloseWithError(err)
return
}
Expand Down

0 comments on commit c3bf4d2

Please sign in to comment.