From 849fc3c1f34519782f28cfb848b00edc77e90926 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 10 Aug 2020 11:04:52 -0400 Subject: [PATCH] rbd: use FormatErrorCode for formatting rbd errors Signed-off-by: John Mulligan --- rbd/errors.go | 7 +------ rbd/errors_test.go | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/rbd/errors.go b/rbd/errors.go index 73336b73fd..5bfc092484 100644 --- a/rbd/errors.go +++ b/rbd/errors.go @@ -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 { diff --git a/rbd/errors_test.go b/rbd/errors_test.go index d37ee4364c..987fa88adb 100644 --- a/rbd/errors_test.go +++ b/rbd/errors_test.go @@ -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)