From f85fec6365c5927b32d82a72052cea242ab70e8c Mon Sep 17 00:00:00 2001 From: Pierre Cauchois Date: Thu, 24 Sep 2020 19:23:48 +0000 Subject: [PATCH] use errors.As() for wrapped ServerError --- lib/eof.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/eof.go b/lib/eof.go index 3023a6ce02..e29d151109 100644 --- a/lib/eof.go +++ b/lib/eof.go @@ -26,12 +26,9 @@ func IsErrEOF(err error) bool { return true } - if srvErr, ok := err.(rpc.ServerError); ok { - return strings.HasSuffix(srvErr.Error(), fmt.Sprintf(": %s", io.EOF.Error())) - } - - if srvErr, ok := errors.Unwrap(err).(rpc.ServerError); ok { - return strings.HasSuffix(srvErr.Error(), fmt.Sprintf(": %s", io.EOF.Error())) + var serverError rpc.ServerError + if errors.As(err, &serverError) { + return strings.HasSuffix(err.Error(), fmt.Sprintf(": %s", io.EOF.Error())) } return false