Skip to content

Commit

Permalink
Try to fix test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Oct 8, 2020
1 parent d1def0f commit 36837c1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/netext/httpext/error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,16 @@ func errorCodeForError(err error) (errCode, string) {
return defaultNetNonTCPErrorCode, err.Error()
}
if sErr, ok := e.Err.(*os.SyscallError); ok {
switch sErr.Err {
switch sErr.Unwrap() {
case syscall.ECONNRESET:
return tcpResetByPeerErrorCode, fmt.Sprintf(tcpResetByPeerErrorCodeMsg, e.Op)
case syscall.EPIPE:
return tcpBrokenPipeErrorCode, fmt.Sprintf(tcpBrokenPipeErrorCodeMsg, e.Op)
}
code, msg := getOSSyscallErrorCode(e, sErr)
if code != 0 {
return code, msg
}
}
if e.Op == "dial" {
if e.Timeout() {
Expand Down
12 changes: 12 additions & 0 deletions lib/netext/httpext/error_codes_syscall_posix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build !windows

package httpext

import (
"net"
"os"
)

func getOSSyscallErrorCode(e *net.OpError, se *os.SyscallError) (errCode, string) {
return 0, ""
}
16 changes: 16 additions & 0 deletions lib/netext/httpext/error_codes_syscall_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package httpext

import (
"fmt"
"net"
"os"
"syscall"
)

func getOSSyscallErrorCode(e *net.OpError, se *os.SyscallError) (errCode, string) {
switch se.Unwrap() {
case syscall.WSAECONNRESET:
return tcpResetByPeerErrorCode, fmt.Sprintf(tcpResetByPeerErrorCodeMsg, e.Op)
}
return 0, ""
}

0 comments on commit 36837c1

Please sign in to comment.