diff --git a/client/status/status.go b/client/status/status.go index a220f2f..0917289 100644 --- a/client/status/status.go +++ b/client/status/status.go @@ -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 diff --git a/client/status/status_test.go b/client/status/status_test.go index 7b8d15f..6dcdd95 100644 --- a/client/status/status_test.go +++ b/client/status/status_test.go @@ -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) { diff --git a/pool/pool.go b/pool/pool.go index fead0e1..450d819 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -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() }