From 57d09895937910280699bceaf5228294b3758216 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 25 Jun 2020 08:41:35 +0200 Subject: [PATCH] cleanup: use errors.As() to compare errors in util/cephcmds See-also: https://github.com/golang/go/wiki/ErrorValueFAQ#how-should-i-change-my-error-handling-code-to-work-with-the-new-features Signed-off-by: Niels de Vos --- internal/util/cephcmds.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/util/cephcmds.go b/internal/util/cephcmds.go index 1940aefca..d2274776a 100644 --- a/internal/util/cephcmds.go +++ b/internal/util/cephcmds.go @@ -19,6 +19,7 @@ package util import ( "bytes" "context" + "errors" "fmt" "io/ioutil" "os" @@ -233,7 +234,8 @@ func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolNam ioctx, err := conn.GetIoctx(poolName) if err != nil { - if _, ok := err.(ErrPoolNotFound); ok { + var epnf ErrPoolNotFound + if errors.As(err, &epnf) { err = ErrObjectNotFound{poolName, err} } return err @@ -267,7 +269,8 @@ func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolNam ioctx, err := conn.GetIoctx(poolName) if err != nil { - if _, ok := err.(ErrPoolNotFound); ok { + var epnf ErrPoolNotFound + if errors.As(err, &epnf) { err = ErrObjectNotFound{poolName, err} } return err