-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
48 lines (39 loc) · 860 Bytes
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package netssh
import (
"fmt"
"net"
"os"
"syscall"
)
type timeouter interface {
Timeout() bool
}
var _ timeouter = &os.PathError{}
type IOError struct {
Cause error
}
var _ net.Error = &IOError{}
func (e IOError) GoString() string {
return fmt.Sprintf("ServeConnIOError:%#v", e.Cause)
}
func (e IOError) Error() string {
// following case found by experiment
if pathErr, ok := e.Cause.(*os.PathError); ok {
if pathErr.Err == syscall.EPIPE {
return fmt.Sprintf("netssh %s: %s (likely: connection reset by peer)",
pathErr.Op, pathErr.Err,
)
}
return fmt.Sprintf("netssh: %s: %s", pathErr.Op, pathErr.Err)
}
return fmt.Sprintf("netssh: %s", e.Cause.Error())
}
func (e IOError) Timeout() bool {
if to, ok := e.Cause.(timeouter); ok {
return to.Timeout()
}
return false
}
func (e IOError) Temporary() bool {
return false
}