From e07f6a6050457c7ba8d2acaf8471b1ba35dab8f1 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 12 Dec 2019 15:30:01 -0500 Subject: [PATCH] rados: replace Println calls with a proper error Replace the odd calls to Println with a comparable error value. Signed-off-by: John Mulligan --- rados/conn.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rados/conn.go b/rados/conn.go index 3317db0..d2b0a25 100644 --- a/rados/conn.go +++ b/rados/conn.go @@ -5,9 +5,15 @@ package rados // #include import "C" -import "unsafe" -import "bytes" -import "fmt" +import ( + "bytes" + "errors" + "unsafe" +) + +var ( + ErrNotConnected = errors.New("RADOS not connected") +) // ClusterStat represents Ceph cluster statistics. type ClusterStat struct { @@ -171,7 +177,7 @@ func (c *Conn) ensure_connected() error { if c.connected { return nil } else { - return RadosError(1) + return ErrNotConnected } } @@ -267,7 +273,6 @@ func (c *Conn) MakePool(name string) error { // DeletePool deletes a pool and all the data inside the pool. func (c *Conn) DeletePool(name string) error { if err := c.ensure_connected(); err != nil { - fmt.Println("NOT CONNECTED WHOOPS") return err } c_name := C.CString(name) @@ -283,7 +288,6 @@ func (c *Conn) DeletePool(name string) error { // GetPoolByName returns the ID of the pool with a given name. func (c *Conn) GetPoolByName(name string) (int64, error) { if err := c.ensure_connected(); err != nil { - fmt.Println("NOT CONNECTED WHOOPS") return 0, err } c_name := C.CString(name) @@ -300,7 +304,6 @@ func (c *Conn) GetPoolByName(name string) (int64, error) { func (c *Conn) GetPoolByID(id int64) (string, error) { buf := make([]byte, 4096) if err := c.ensure_connected(); err != nil { - fmt.Println("NOT CONNECTED WHOOPS") return "", err } c_id := C.int64_t(id)