os: add SyscallError.Timeout

Signed-off-by: Roman Volosatovs <roman@profian.com>
This commit is contained in:
Roman Volosatovs
2022-07-08 17:24:42 +02:00
committed by Ron Evans
parent 9e7667ffae
commit 9d73e6cfe4
+10
View File
@@ -70,6 +70,16 @@ func (e *SyscallError) Error() string { return e.Syscall + ": " + e.Err.Error()
func (e *SyscallError) Unwrap() error { return e.Err }
type timeout interface {
Timeout() bool
}
// Timeout reports whether this error represents a timeout.
func (e *SyscallError) Timeout() bool {
t, ok := e.Err.(timeout)
return ok && t.Timeout()
}
func IsExist(err error) bool {
return underlyingErrorIs(err, ErrExist)
}