From 9ab9e3c40bbb33c6f37359c87508cbc6a9830ed6 Mon Sep 17 00:00:00 2001 From: Samuel Stauffer Date: Wed, 13 Dec 2023 17:44:10 -0800 Subject: [PATCH] Unwrap errors in normalizeTimeoutError --- pgconn/errors.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pgconn/errors.go b/pgconn/errors.go index 3c54bbec..61957829 100644 --- a/pgconn/errors.go +++ b/pgconn/errors.go @@ -107,14 +107,15 @@ func (e *parseConfigError) Unwrap() error { } func normalizeTimeoutError(ctx context.Context, err error) error { - if err, ok := err.(net.Error); ok && err.Timeout() { + var netErr net.Error + if errors.As(err, &netErr) && netErr.Timeout() { if ctx.Err() == context.Canceled { // Since the timeout was caused by a context cancellation, the actual error is context.Canceled not the timeout error. return context.Canceled } else if ctx.Err() == context.DeadlineExceeded { return &errTimeout{err: ctx.Err()} } else { - return &errTimeout{err: err} + return &errTimeout{err: netErr} } } return err