mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 00:10:20 +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 (
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user