From 69501f6302f9621716b206a1275c2c7d17b6a3f8 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 2 Oct 2024 12:13:50 +0200 Subject: [PATCH] feat: log context cancelled error as warn instead of errors --- internal/proxy/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/proxy/server.go b/internal/proxy/server.go index aca2c48..efd2be9 100644 --- a/internal/proxy/server.go +++ b/internal/proxy/server.go @@ -232,7 +232,12 @@ func (s *Server) handleDefault(w http.ResponseWriter, r *http.Request) { func (s *Server) handleError(w http.ResponseWriter, r *http.Request, status int, err error) { err = errors.WithStack(err) - logger.Error(r.Context(), err.Error(), logger.CapturedE(err)) + + if errors.Is(err, context.Canceled) { + logger.Warn(r.Context(), err.Error(), logger.CapturedE(err)) + } else { + logger.Error(r.Context(), err.Error(), logger.CapturedE(err)) + } s.renderErrorPage(w, r, err, status, http.StatusText(status)) }