From bcb66037062e285f9548a3d78fb40eb68cb0cb87 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 2 Apr 2023 20:15:55 +0200 Subject: Catch most of the remaining errors Including fixes of some nits. --- internal/qna/qna.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/qna/qna.go b/internal/qna/qna.go index 3ad942c..1a016b0 100644 --- a/internal/qna/qna.go +++ b/internal/qna/qna.go @@ -142,7 +142,7 @@ func isConnError(err error) bool { if !ok { return false } - if urlErr.Err.Error() == "EOF" { + if str := urlErr.Err.Error(); str == "EOF" || str == "unexpected EOF" { return true } opErr, ok := urlErr.Err.(*net.OpError) @@ -161,10 +161,10 @@ func isTLSError(err error) bool { if !ok { return false } - if urlErr.Error() == "http: server gave HTTP response to HTTPS client" { + if urlErr.Err.Error() == "http: server gave HTTP response to HTTPS client" { return true } - return strings.Contains(urlErr.Error(), "tls: ") + return strings.Contains(urlErr.Err.Error(), "tls: ") } func isTLSCertError(err error) bool { @@ -183,7 +183,11 @@ func is3xxErr(err error) bool { func isDeadlineError(err error) bool { urlErr, ok := err.(*url.Error) - return ok && errors.Is(urlErr.Err, context.DeadlineExceeded) + if ok && errors.Is(urlErr.Err, context.DeadlineExceeded) { + return true + } + opErr, ok := urlErr.Err.(*net.OpError) + return ok && opErr.Err.Error() == "i/o timeout" } func TrimWildcard(san string) string { -- cgit v1.2.3