diff --git a/backend/server/internal/server/middleware.go b/backend/server/internal/server/middleware.go index f00c337..9cdfe32 100644 --- a/backend/server/internal/server/middleware.go +++ b/backend/server/internal/server/middleware.go @@ -106,7 +106,7 @@ func withLogging(s *statsd.Client, out io.Writer) Middleware { } } -// withPanicGuard is the last defence from a panic. it will log them and return a 500 error +// withPanicGuard is the last defence from a panic. it will log them and return a 503 error // to the client and prevent the http server from breaking func withPanicGuard() Middleware { return func(h http.Handler) http.Handler { diff --git a/backend/server/internal/server/middleware_test.go b/backend/server/internal/server/middleware_test.go index 1a95fcb..5a0b4b1 100644 --- a/backend/server/internal/server/middleware_test.go +++ b/backend/server/internal/server/middleware_test.go @@ -101,8 +101,8 @@ func TestPanicGuard(t *testing.T) { if panicked { t.Fatalf("expected no panic") } - if w.Code != http.StatusInternalServerError { - t.Errorf("expected status %d, got %d", http.StatusInternalServerError, w.Code) + if w.Code != http.StatusServiceUnavailable { + t.Errorf("expected status %d, got %d", http.StatusServiceUnavailable, w.Code) } } @@ -162,7 +162,7 @@ func TestMergeMiddlewares(t *testing.T) { { name: "panics", handler: panicHandler, - expectedStatusCode: http.StatusInternalServerError, + expectedStatusCode: http.StatusServiceUnavailable, expectedPieces: []string{ `oh no`, `127.0.0.1 GET "/"`,