mirror of https://github.com/ceph/go-ceph
rbd: use FormatErrorCode for formatting rbd errors
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
b6dff699e4
commit
849fc3c1f3
|
@ -7,7 +7,6 @@ import "C"
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/ceph/go-ceph/internal/errutil"
|
||||
)
|
||||
|
@ -16,11 +15,7 @@ import (
|
|||
type rbdError int
|
||||
|
||||
func (e rbdError) Error() string {
|
||||
errno, s := errutil.FormatErrno(int(e))
|
||||
if s == "" {
|
||||
return fmt.Sprintf("rbd: ret=%d", errno)
|
||||
}
|
||||
return fmt.Sprintf("rbd: ret=%d, %s", errno, s)
|
||||
return errutil.FormatErrorCode("rbd", int(e))
|
||||
}
|
||||
|
||||
func (e rbdError) ErrorCode() int {
|
||||
|
|
|
@ -13,7 +13,7 @@ func TestRBDError(t *testing.T) {
|
|||
|
||||
err = getError(-39) // NOTEMPTY (image still has a snapshot)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, err.Error(), "rbd: ret=39, Directory not empty")
|
||||
assert.Equal(t, err.Error(), "rbd: ret=-39, Directory not empty")
|
||||
|
||||
errno, ok := err.(interface{ ErrorCode() int })
|
||||
assert.True(t, ok)
|
||||
|
|
Loading…
Reference in New Issue