client: Fix error checking for go 1.18-19

Should be reverted/updated when minimum version of Go will be set to 1.20

Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
Evgenii Baidakov 2023-05-16 15:44:58 +04:00
parent a4e14ab35b
commit e0afe0807c
No known key found for this signature in database
GPG key ID: 8733EE3D72CDB4DE
5 changed files with 21 additions and 19 deletions

View file

@ -45,7 +45,7 @@ func (x ServerInternal) Error() string {
func (x ServerInternal) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ServerInternal, *ServerInternal:
return true
}
@ -103,7 +103,7 @@ func (x WrongMagicNumber) Error() string {
func (x WrongMagicNumber) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case WrongMagicNumber, *WrongMagicNumber:
return true
}
@ -188,7 +188,7 @@ func (x SignatureVerification) Error() string {
func (x SignatureVerification) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case SignatureVerification, *SignatureVerification:
return true
}
@ -257,7 +257,7 @@ func (x NodeUnderMaintenance) Error() string {
func (x NodeUnderMaintenance) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case NodeUnderMaintenance, *NodeUnderMaintenance:
return true
}

View file

@ -1,6 +1,8 @@
package apistatus
import (
"errors"
"github.com/nspcc-dev/neofs-api-go/v2/container"
"github.com/nspcc-dev/neofs-api-go/v2/status"
)
@ -38,7 +40,7 @@ func (x ContainerNotFound) Error() string {
func (x ContainerNotFound) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ContainerNotFound, *ContainerNotFound:
return true
}
@ -86,7 +88,7 @@ func (x EACLNotFound) Error() string {
func (x EACLNotFound) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case EACLNotFound, *EACLNotFound:
return true
}

View file

@ -1,6 +1,8 @@
package apistatus
import (
"errors"
"github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/status"
)
@ -50,7 +52,7 @@ func (x ObjectLocked) Error() string {
func (x ObjectLocked) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ObjectLocked, *ObjectLocked:
return true
}
@ -97,7 +99,7 @@ func (x LockNonRegularObject) Error() string {
func (x LockNonRegularObject) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case LockNonRegularObject, *LockNonRegularObject:
return true
}
@ -144,7 +146,7 @@ func (x ObjectAccessDenied) Error() string {
func (x ObjectAccessDenied) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ObjectAccessDenied, *ObjectAccessDenied:
return true
}
@ -202,7 +204,7 @@ func (x ObjectNotFound) Error() string {
func (x ObjectNotFound) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ObjectNotFound, *ObjectNotFound:
return true
}
@ -249,7 +251,7 @@ func (x ObjectAlreadyRemoved) Error() string {
func (x ObjectAlreadyRemoved) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ObjectAlreadyRemoved, *ObjectAlreadyRemoved:
return true
}
@ -297,7 +299,7 @@ func (x ObjectOutOfRange) Error() string {
func (x ObjectOutOfRange) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case ObjectOutOfRange, *ObjectOutOfRange:
return true
}

View file

@ -1,6 +1,8 @@
package apistatus
import (
"errors"
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-api-go/v2/status"
)
@ -38,7 +40,7 @@ func (x SessionTokenNotFound) Error() string {
func (x SessionTokenNotFound) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case SessionTokenNotFound, *SessionTokenNotFound:
return true
}
@ -85,7 +87,7 @@ func (x SessionTokenExpired) Error() string {
func (x SessionTokenExpired) Is(target error) bool {
switch target.(type) {
default:
return false
return errors.Is(Error, target)
case SessionTokenExpired, *SessionTokenExpired:
return true
}

View file

@ -1,9 +1,5 @@
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:
@ -26,7 +22,7 @@ type Status any
// Note: direct assignment may not be compatibility-safe.
func ErrFromStatus(st Status) error {
if err, ok := st.(error); ok {
return errors.Join(Error, err)
return err
}
return nil