Skip to content

Commit

Permalink
rbd: use FormatErrorCode for formatting rbd errors
Browse files Browse the repository at this point in the history
Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed Aug 10, 2020
1 parent b6dff69 commit 849fc3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions rbd/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "C"

import (
"errors"
"fmt"

"github.com/ceph/go-ceph/internal/errutil"
)
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rbd/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 849fc3c

Please sign in to comment.