diff --git a/rados/errors.go b/rados/errors.go index a0a591b..6039d12 100644 --- a/rados/errors.go +++ b/rados/errors.go @@ -7,7 +7,6 @@ import "C" import ( "errors" - "fmt" "github.com/ceph/go-ceph/internal/errutil" ) @@ -17,11 +16,7 @@ type radosError int // Error returns the error string for the radosError type. func (e radosError) Error() string { - errno, s := errutil.FormatErrno(int(e)) - if s == "" { - return fmt.Sprintf("rados: ret=%d", errno) - } - return fmt.Sprintf("rados: ret=%d, %s", errno, s) + return errutil.FormatErrorCode("rados", int(e)) } func (e radosError) ErrorCode() int { diff --git a/rados/errors_test.go b/rados/errors_test.go index 4197e73..4564d81 100644 --- a/rados/errors_test.go +++ b/rados/errors_test.go @@ -13,7 +13,7 @@ func TestRadosError(t *testing.T) { err = getError(-5) // IO error assert.Error(t, err) - assert.Equal(t, err.Error(), "rados: ret=5, Input/output error") + assert.Equal(t, err.Error(), "rados: ret=-5, Input/output error") errno, ok := err.(interface{ ErrorCode() int }) assert.True(t, ok)