forked from TrueCloudLab/frostfs-sdk-go
client: Replace apistatus type check with error check
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
parent
483aff30c0
commit
1d952ced4e
3 changed files with 10 additions and 7 deletions
|
@ -1,5 +1,9 @@
|
|||
package apistatus
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Status defines a variety of NeoFS API status returns.
|
||||
//
|
||||
// All statuses are split into two disjoint subsets: successful and failed, and:
|
||||
|
@ -22,7 +26,7 @@ type Status any
|
|||
// Note: direct assignment may not be compatibility-safe.
|
||||
func ErrFromStatus(st Status) error {
|
||||
if err, ok := st.(error); ok {
|
||||
return err
|
||||
return errors.Join(Error, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestErrors(t *testing.T) {
|
|||
|
||||
res := apistatus.ErrFromStatus(st)
|
||||
|
||||
require.Equal(t, err, res)
|
||||
require.ErrorIs(t, res, err)
|
||||
})
|
||||
|
||||
t.Run("non-error source", func(t *testing.T) {
|
||||
|
|
|
@ -992,11 +992,10 @@ func (c *clientStatusMonitor) handleError(st apistatus.Status, err error) error
|
|||
}
|
||||
|
||||
err = apistatus.ErrFromStatus(st)
|
||||
switch err.(type) {
|
||||
case apistatus.ServerInternal, *apistatus.ServerInternal,
|
||||
apistatus.WrongMagicNumber, *apistatus.WrongMagicNumber,
|
||||
apistatus.SignatureVerification, *apistatus.SignatureVerification,
|
||||
apistatus.NodeUnderMaintenance, *apistatus.NodeUnderMaintenance:
|
||||
if errors.Is(err, apistatus.ErrServerInternal) ||
|
||||
errors.Is(err, apistatus.ErrWrongMagicNumber) ||
|
||||
errors.Is(err, apistatus.ErrSignatureVerification) ||
|
||||
errors.Is(err, apistatus.ErrNodeUnderMaintenance) {
|
||||
c.incErrorRate()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue