diff options
author | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 20:15:55 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 20:15:55 +0200 |
commit | bcb66037062e285f9548a3d78fb40eb68cb0cb87 (patch) | |
tree | 45b46eea0276d40922d5cde62047bfc59163ebfd | |
parent | de1f0b86f6636ae7c8b59edf0570cd5ee37ebc63 (diff) |
Catch most of the remaining errors
Including fixes of some nits.
-rw-r--r-- | internal/qna/qna.go | 12 |
1 files changed, 8 insertions, 4 deletions
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 { |