Skip to content

Commit

Permalink
Fix errorCodeForError() to recognize DNS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Apr 6, 2021
1 parent 2c2ca60 commit d14d24d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/netext/httpext/error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func errorCodeForError(err error) (errCode, string) {
return unknownHTTP2ConnectionErrorCode + http2ErrCodeOffset(http2.ErrCode(*e)),
fmt.Sprintf(http2ConnectionErrorCodeMsg, http2.ErrCode(*e))
case *net.OpError:
// TODO: refactor this branch and actually check for *os.SyscallError in
// the main switch body?

if e.Net != "tcp" && e.Net != "tcp6" {
// TODO: figure out how this happens
return defaultNetNonTCPErrorCode, err.Error()
Expand Down Expand Up @@ -172,6 +175,16 @@ func errorCodeForError(err error) (errCode, string) {
fmt.Sprintf("dial: unknown errno %d error with msg `%s`", errno, iErr.Err)
}
}

// Check if the wrapped error isn't something we recognize, e.g. a DNS error
if wrappedErr := errors.Unwrap(err); wrappedErr != nil {
errCodeForWrapped, errForWrapped := errorCodeForError(wrappedErr)
if errCodeForWrapped != defaultErrorCode {
return errCodeForWrapped, errForWrapped
}
}

// If it's not, return a generic TCP dial error
return tcpDialErrorCode, err.Error()
}
switch inErr := e.Err.(type) {
Expand Down

0 comments on commit d14d24d

Please sign in to comment.