From 9d73e6cfe4e245fee0e4175ac43991f41aec68bc Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Fri, 8 Jul 2022 17:24:42 +0200 Subject: [PATCH] os: add SyscallError.Timeout Signed-off-by: Roman Volosatovs --- src/os/errors.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/os/errors.go b/src/os/errors.go index 83f04b0f..74c77c90 100644 --- a/src/os/errors.go +++ b/src/os/errors.go @@ -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) }