mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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:
parent
8c4379862a
commit
57d0989593
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user