rados: convert to common errno handling

Use the errno handling function originally created for rbd and
then made common in rados package.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2019-12-12 14:02:30 -05:00 committed by Niels de Vos
parent b6ad17881a
commit bd99f64517
1 changed files with 7 additions and 1 deletions

View File

@ -10,12 +10,18 @@ import (
"fmt"
"runtime"
"unsafe"
"github.com/ceph/go-ceph/errutil"
)
type RadosError int
func (e RadosError) Error() string {
return fmt.Sprintf("rados: %s", C.GoString(C.strerror(C.int(-e))))
errno, s := errutil.FormatErrno(int(e))
if s == "" {
return fmt.Sprintf("rados: ret=%d", errno)
}
return fmt.Sprintf("rados: ret=%d, %s", errno, s)
}
var RadosAllNamespaces = C.LIBRADOS_ALL_NSPACES