From 2738b2a845e4ad1ce7ed22b6de09bd1a19de944c 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 83f04b0fa3..74c77c902d 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) }