1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-19 19:40:19 +00:00

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 <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-25 08:41:35 +02:00 committed by mergify[bot]
parent 8c4379862a
commit 57d0989593

View File

@ -19,6 +19,7 @@ package util
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -233,7 +234,8 @@ func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolNam
ioctx, err := conn.GetIoctx(poolName) ioctx, err := conn.GetIoctx(poolName)
if err != nil { if err != nil {
if _, ok := err.(ErrPoolNotFound); ok { var epnf ErrPoolNotFound
if errors.As(err, &epnf) {
err = ErrObjectNotFound{poolName, err} err = ErrObjectNotFound{poolName, err}
} }
return err return err
@ -267,7 +269,8 @@ func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolNam
ioctx, err := conn.GetIoctx(poolName) ioctx, err := conn.GetIoctx(poolName)
if err != nil { if err != nil {
if _, ok := err.(ErrPoolNotFound); ok { var epnf ErrPoolNotFound
if errors.As(err, &epnf) {
err = ErrObjectNotFound{poolName, err} err = ErrObjectNotFound{poolName, err}
} }
return err return err