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 c55c414
Show file tree
Hide file tree
Showing 3 changed files with 29 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(sErr)
if code != 0 {
return code, msg
}
}
if e.Op == "dial" {
if e.Timeout() {
Expand Down
9 changes: 9 additions & 0 deletions lib/netext/httpext/error_codes_syscall_posix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// +build !windows

package httpext

import "os"

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

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

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

0 comments on commit c55c414

Please sign in to comment.