Skip to content

Commit 57de1cd

Browse files
committed
os: add SyscallError.Timeout
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent cc67dad commit 57de1cd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/os/errors.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ func (e *SyscallError) Error() string { return e.Syscall + ": " + e.Err.Error()
7070

7171
func (e *SyscallError) Unwrap() error { return e.Err }
7272

73+
type timeout interface {
74+
Timeout() bool
75+
}
76+
77+
// Timeout reports whether this error represents a timeout.
78+
func (e *SyscallError) Timeout() bool {
79+
t, ok := e.Err.(timeout)
80+
return ok && t.Timeout()
81+
}
82+
7383
func IsExist(err error) bool {
7484
return underlyingErrorIs(err, ErrExist)
7585
}

0 commit comments

Comments
 (0)