2
0

Unwrap errors in normalizeTimeoutError

This commit is contained in:
Samuel Stauffer
2023-12-13 17:44:10 -08:00
committed by Jack Christensen
parent 2daeb8dc5f
commit 9ab9e3c40b
+3 -2
View File
@@ -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