logWithNonCrit logs the error on the appropriate level depending on whether err is a critical error or not.
(ctx context.Context, err error, msg string, proto Proto, l *slog.Logger)
| 222 | // logWithNonCrit logs the error on the appropriate level depending on whether |
| 223 | // err is a critical error or not. |
| 224 | func logWithNonCrit(ctx context.Context, err error, msg string, proto Proto, l *slog.Logger) { |
| 225 | if errors.Is(err, io.EOF) || errors.Is(err, net.ErrClosed) || isEPIPE(err) { |
| 226 | l.DebugContext( |
| 227 | ctx, |
| 228 | "connection is closed", |
| 229 | "proto", proto, |
| 230 | "details", msg, |
| 231 | slogutil.KeyError, err, |
| 232 | ) |
| 233 | } else if netErr := net.Error(nil); errors.As(err, &netErr) && netErr.Timeout() { |
| 234 | l.DebugContext( |
| 235 | ctx, |
| 236 | "connection timed out", |
| 237 | "proto", proto, |
| 238 | "details", msg, |
| 239 | slogutil.KeyError, err, |
| 240 | ) |
| 241 | } else { |
| 242 | l.ErrorContext(ctx, msg, "proto", proto, slogutil.KeyError, err) |
| 243 | } |
| 244 | } |
no test coverage detected
searching dependent graphs…