util: simplify error handling

The sentinel error code had additional fields in the errors, that are
used nowhere.  This leads to unneccesarily complicated code.  This
change replaces the sentinel errors in utils with standard errors
created with errors.New() and adds a simple JoinErrors() function to
be able to combine sentinel errors from different code tiers.

Related: #1203

Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
Sven Anderson
2020-07-09 01:00:23 +02:00
committed by mergify[bot]
parent c277ed588d
commit 8393fbe40b
8 changed files with 74 additions and 145 deletions

View File

@ -74,7 +74,7 @@ func (cc *ClusterConnection) GetIoctx(pool string) (*rados.IOContext, error) {
if err != nil {
// ErrNotFound indicates the Pool was not found
if errors.Is(err, rados.ErrNotFound) {
err = ErrPoolNotFound{pool, err}
err = JoinErrors(ErrPoolNotFound, err)
} else {
err = fmt.Errorf("failed to open IOContext for pool %s: %w", pool, err)
}