mirror of https://github.com/ceph/go-ceph
cephfs: add a getErrorIfNegative helper func
Works like the ones already in the other packages. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
837777d3fc
commit
65227dd4d4
|
@ -35,6 +35,16 @@ func getError(e C.int) error {
|
|||
return cephFSError(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 (
|
||||
|
|
Loading…
Reference in New Issue