diff --git a/rados/conn.go b/rados/conn.go index d1040f5..69a29bc 100644 --- a/rados/conn.go +++ b/rados/conn.go @@ -273,7 +273,7 @@ func (c *Conn) GetPoolByName(name string) (int64, error) { defer C.free(unsafe.Pointer(c_name)) ret := int64(C.rados_pool_lookup(c.cluster, c_name)) if ret < 0 { - return 0, RadosError(ret) + return 0, radosError(ret) } return ret, nil } @@ -287,7 +287,7 @@ func (c *Conn) GetPoolByID(id int64) (string, error) { c_id := C.int64_t(id) ret := int(C.rados_pool_reverse_lookup(c.cluster, c_id, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))) if ret < 0 { - return "", RadosError(ret) + return "", radosError(ret) } return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil } diff --git a/rados/errors.go b/rados/errors.go index 3cd5f00..7be2423 100644 --- a/rados/errors.go +++ b/rados/errors.go @@ -12,15 +12,11 @@ import ( "github.com/ceph/go-ceph/internal/errutil" ) -// revive:disable:exported Temporarily live with stuttering +// radosError represents an error condition returned from the Ceph RADOS APIs. +type radosError int -// RadosError represents an error condition returned from the Ceph RADOS APIs. -type RadosError int - -// revive:enable:exported - -// Error returns the error string for the RadosError type. -func (e RadosError) Error() string { +// Error returns the error string for the radosError type. +func (e radosError) Error() string { errno, s := errutil.FormatErrno(int(e)) if s == "" { return fmt.Sprintf("rados: ret=%d", errno) @@ -28,11 +24,15 @@ func (e RadosError) Error() string { return fmt.Sprintf("rados: ret=%d, %s", errno, s) } +func (e radosError) Errno() int { + return int(e) +} + func getError(e C.int) error { if e == 0 { return nil } - return RadosError(e) + return radosError(e) } // getErrorIfNegative converts a ceph return code to error if negative. @@ -52,15 +52,15 @@ var ( ErrNotConnected = errors.New("RADOS not connected") ) -// Public RadosErrors: +// Public radosErrors: const ( // ErrNotFound indicates a missing resource. - ErrNotFound = RadosError(-C.ENOENT) + ErrNotFound = radosError(-C.ENOENT) // ErrPermissionDenied indicates a permissions issue. - ErrPermissionDenied = RadosError(-C.EPERM) + ErrPermissionDenied = radosError(-C.EPERM) // ErrObjectExists indicates that an exclusive object creation failed. - ErrObjectExists = RadosError(-C.EEXIST) + ErrObjectExists = radosError(-C.EEXIST) // RadosErrorNotFound indicates a missing resource. // @@ -75,7 +75,7 @@ const ( // Private errors: const ( - errNameTooLong = RadosError(-C.ENAMETOOLONG) + errNameTooLong = radosError(-C.ENAMETOOLONG) - errRange = RadosError(-C.ERANGE) + errRange = radosError(-C.ERANGE) ) diff --git a/rados/ioctx.go b/rados/ioctx.go index b0663cc..c6f4ac6 100644 --- a/rados/ioctx.go +++ b/rados/ioctx.go @@ -589,7 +589,7 @@ func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error) { } if ret < 0 { - return nil, RadosError(ret) + return nil, radosError(ret) } return &LockInfo{int(ret), c_exclusive == 1, C.GoString(c_tag), splitCString(c_clients, c_clients_len), splitCString(c_cookies, c_cookies_len), splitCString(c_addrs, c_addrs_len)}, nil }