use errors.As() for wrapped ServerError

This commit is contained in:
Pierre Cauchois 2020-09-24 19:23:48 +00:00
parent 352cf930fc
commit f85fec6365
1 changed files with 3 additions and 6 deletions

View File

@ -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