mirror of
https://github.com/ceph/go-ceph
synced 2024-12-22 06:10:09 +00:00
cephfs: use FormatErrorCode for formatting cephfs errors
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
828ea92a51
commit
33e84bc9c5
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user