Skip to content

Commit

Permalink
xxx: improve error handling
Browse files Browse the repository at this point in the history
Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed May 21, 2020
1 parent 4278fb8 commit 180f674
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/journal/omap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func getOneOMapValue(
// fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil {
return "", err
return "", omapPoolError(poolName, err)
}
defer ioctx.Destroy()

if namespace != "" {
ioctx.SetNamespace(namespace)
}
Expand Down Expand Up @@ -60,7 +61,7 @@ func removeOneOMapKey(
// fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil {
return err
return omapPoolError(poolName, err)
}
defer ioctx.Destroy()

Expand Down Expand Up @@ -88,7 +89,7 @@ func setOneOMapKey(
// fetch and configure the rados ioctx
ioctx, err := conn.conn.GetIoctx(poolName)
if err != nil {
return err
return omapPoolError(poolName, err)
}
defer ioctx.Destroy()

Expand All @@ -111,3 +112,10 @@ func setOneOMapKey(
}
return err
}

func omapPoolError(poolName string, err error) error {
if err == rados.ErrNotFound {
return util.NewErrPoolNotFound(poolName, err)
}
return err
}
4 changes: 4 additions & 0 deletions internal/util/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ type ErrPoolNotFound struct {
func (e ErrPoolNotFound) Error() string {
return e.Err.Error()
}

func NewErrPoolNotFound(pool string, err error) ErrPoolNotFound {
return ErrPoolNotFound{pool, err}
}

0 comments on commit 180f674

Please sign in to comment.