ceph-csi/vendor/github.com/ceph/go-ceph/cephfs/errors.go
dependabot[bot] 42db99ac5b rebase: bump github.com/ceph/go-ceph
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.30.1-0.20241102143109-75d1af3ed638 to 0.31.0.
- [Release notes](https://github.com/ceph/go-ceph/releases)
- [Changelog](https://github.com/ceph/go-ceph/blob/master/docs/release-process.md)
- [Commits](https://github.com/ceph/go-ceph/commits/v0.31.0)

---
updated-dependencies:
- dependency-name: github.com/ceph/go-ceph
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-07 14:10:18 +00:00

50 lines
1.2 KiB
Go

package cephfs
/*
#include <errno.h>
*/
import "C"
import (
"errors"
"github.com/ceph/go-ceph/internal/errutil"
)
func getError(e C.int) error {
return errutil.GetError("cephfs", int(e))
}
// getErrorIfNegative converts a ceph return code to error if negative.
// This is useful for functions that return a usable positive value on
// success but a negative error number on error.
func getErrorIfNegative(ret C.int) error {
if ret >= 0 {
return nil
}
return getError(ret)
}
// Public go errors:
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")
// ErrNotConnected may be returned when client is not connected
// to a cluster.
ErrNotConnected = getError(-C.ENOTCONN)
// ErrNotExist indicates a non-specific missing resource.
ErrNotExist = getError(-C.ENOENT)
// ErrOpNotSupported is returned in general for operations that are not
// supported.
ErrOpNotSupported = getError(-C.EOPNOTSUPP)
// Private errors:
errInvalid = getError(-C.EINVAL)
errNameTooLong = getError(-C.ENAMETOOLONG)
errRange = getError(-C.ERANGE)
)