cephfs: use FormatErrorCode for formatting cephfs errors

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-08-10 11:04:07 -04:00 committed by John Mulligan
parent 828ea92a51
commit 33e84bc9c5
2 changed files with 2 additions and 7 deletions

View File

@ -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 {

View File

@ -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)