Skip to content

Commit

Permalink
cephfs: replace cephfsError by cephError
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic authored and mergify[bot] committed Oct 14, 2024
1 parent 3dbd875 commit b712180
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions cephfs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,8 @@ import (
"github.com/ceph/go-ceph/internal/errutil"
)

// cephFSError represents an error condition returned from the CephFS APIs.
type cephFSError int

// Error returns the error string for the cephFSError type.
func (e cephFSError) Error() string {
return errutil.FormatErrorCode("cephfs", int(e))
}

func (e cephFSError) ErrorCode() int {
return int(e)
}

func getError(e C.int) error {
if e == 0 {
return nil
}
return cephFSError(e)
return errutil.GetError("cephfs", int(e))
}

// getErrorIfNegative converts a ceph return code to error if negative.
Expand All @@ -46,22 +31,16 @@ var (
// ErrEmptyArgument may be returned if a function argument is passed
// a zero-length slice or map.
ErrEmptyArgument = errors.New("Argument must contain at least one item")
)

// Public CephFSErrors:

const (
// ErrNotConnected may be returned when client is not connected
// to a cluster.
ErrNotConnected = cephFSError(-C.ENOTCONN)
ErrNotConnected = getError(-C.ENOTCONN)
// ErrNotExist indicates a non-specific missing resource.
ErrNotExist = cephFSError(-C.ENOENT)
)
ErrNotExist = getError(-C.ENOENT)

// Private errors:
// Private errors:

const (
errInvalid = cephFSError(-C.EINVAL)
errNameTooLong = cephFSError(-C.ENAMETOOLONG)
errRange = cephFSError(-C.ERANGE)
errInvalid = getError(-C.EINVAL)
errNameTooLong = getError(-C.ENAMETOOLONG)
errRange = getError(-C.ERANGE)
)

0 comments on commit b712180

Please sign in to comment.