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