Remove unnecessary joinError unwrap
Signed-off-by: Jin Dong <jin.dong@databricks.com>
This commit is contained in:
parent
cd8c8ae4bc
commit
6d8329d7f5
@ -209,20 +209,7 @@ func (p *PoolDevice) transition(ctx context.Context, deviceName string, tryingSt
|
||||
result = append(result, uerr)
|
||||
}
|
||||
|
||||
return unwrapError(errors.Join(result...))
|
||||
}
|
||||
|
||||
func unwrapError(e error) error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if joinErr, ok := e.(interface{ Unwrap() []error }); ok {
|
||||
if errs := joinErr.Unwrap(); len(errs) == 1 {
|
||||
return errs[0]
|
||||
}
|
||||
}
|
||||
return e
|
||||
return errors.Join(result...)
|
||||
}
|
||||
|
||||
// CreateThinDevice creates new devmapper thin-device with given name and size.
|
||||
|
@ -140,11 +140,6 @@ func (ms *MetaStore) WithTransaction(ctx context.Context, writable bool, fn Tran
|
||||
|
||||
if err := errors.Join(result...); err != nil {
|
||||
log.G(ctx).WithError(err).Debug("snapshotter error")
|
||||
|
||||
// Unwrap if just one error
|
||||
if errs, ok := err.(interface{ Unwrap() []error }); ok && len(errs.Unwrap()) == 1 {
|
||||
return errs.Unwrap()[0]
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user