From eb3d3ca818e3947f59e5b1a15a5ef9a5d32e71e1 Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Wed, 10 Jan 2024 15:30:55 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=81=AB=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=82=8B=20status=20code=20=E3=81=8C?= =?UTF-8?q?=E5=AE=9F=E9=9A=9B=E3=81=AE=E3=82=82=E3=81=AE=E3=81=8B=E3=82=89?= =?UTF-8?q?=E5=A4=89=E3=82=8F=E3=82=8B=E3=81=9F=E3=82=81=E3=80=81stream=20?= =?UTF-8?q?=E5=87=A6=E7=90=86=E9=96=8B=E5=A7=8B=E5=BE=8C=E3=81=AF=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E3=81=9D=E3=81=AE=E3=81=BE=E3=81=BE?= =?UTF-8?q?=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler.go | 10 +++++----- test_handler_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/handler.go b/handler.go index d05fd29..3acf57a 100644 --- a/handler.go +++ b/handler.go @@ -153,7 +153,7 @@ func (s *Server) createSpeechHandler(serviceType string, onResultFunc func(conte Str("channel_id", h.SoraChannelID). Str("connection_id", h.SoraConnectionID). Send() - return echo.NewHTTPError(499) + return err } else if errors.Is(err, ErrServerDisconnected) { if *s.config.Retry { // サーバから切断されたが再度接続できる可能性があるため、接続を試みる @@ -173,7 +173,7 @@ func (s *Server) createSpeechHandler(serviceType string, onResultFunc func(conte Str("channel_id", h.SoraChannelID). Str("connection_id", h.SoraConnectionID). Send() - return echo.NewHTTPError(http.StatusInternalServerError) + return err } } @@ -182,8 +182,8 @@ func (s *Server) createSpeechHandler(serviceType string, onResultFunc func(conte Str("channel_id", h.SoraChannelID). Str("connection_id", h.SoraConnectionID). Send() - // サーバから切断されたが再度の接続が期待できない場合、または、想定外のエラーの場合は InternalServerError - return echo.NewHTTPError(http.StatusInternalServerError) + // サーバから切断されたが再度の接続が期待できない場合 + return err } // メッセージが空でない場合はクライアントに結果を送信する @@ -194,7 +194,7 @@ func (s *Server) createSpeechHandler(serviceType string, onResultFunc func(conte Str("channel_id", h.SoraChannelID). Str("connection_id", h.SoraConnectionID). Send() - return echo.NewHTTPError(http.StatusInternalServerError) + return err } c.Response().Flush() } diff --git a/test_handler_test.go b/test_handler_test.go index 33aba9f..43fe17a 100644 --- a/test_handler_test.go +++ b/test_handler_test.go @@ -268,7 +268,7 @@ func TestSpeechHandler(t *testing.T) { h := s.createSpeechHandler(serviceType, nil) err = h(c) if assert.Error(t, err) { - assert.Equal(t, http.StatusInternalServerError, err.(*echo.HTTPError).Code) + assert.Equal(t, "packet read error", err.Error()) } pw.Close() @@ -354,7 +354,7 @@ func TestSpeechHandler(t *testing.T) { }) err := h(c) if assert.Error(t, err) { - assert.Equal(t, http.StatusInternalServerError, err.(*echo.HTTPError).Code) + assert.Equal(t, "ON-RESULT-ERROR", err.Error()) } })