Skip to content

Commit

Permalink
client: Fix error checking for go 1.18-19
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed May 16, 2023
1 parent 1288a13 commit 890364b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 59 deletions.
8 changes: 4 additions & 4 deletions client/status/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(ErrAPI, target)
case ServerInternal, *ServerInternal:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case WrongMagicNumber, *WrongMagicNumber:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case SignatureVerification, *SignatureVerification:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case NodeUnderMaintenance, *NodeUnderMaintenance:
return true
}
Expand Down
6 changes: 4 additions & 2 deletions client/status/container.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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(ErrAPI, target)
case ContainerNotFound, *ContainerNotFound:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case EACLNotFound, *EACLNotFound:
return true
}
Expand Down
44 changes: 0 additions & 44 deletions client/status/join_errors.go

This file was deleted.

14 changes: 8 additions & 6 deletions client/status/object.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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(ErrAPI, target)
case ObjectLocked, *ObjectLocked:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case LockNonRegularObject, *LockNonRegularObject:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case ObjectAccessDenied, *ObjectAccessDenied:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case ObjectNotFound, *ObjectNotFound:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case ObjectAlreadyRemoved, *ObjectAlreadyRemoved:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case ObjectOutOfRange, *ObjectOutOfRange:
return true
}
Expand Down
6 changes: 4 additions & 2 deletions client/status/session.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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(ErrAPI, target)
case SessionTokenNotFound, *SessionTokenNotFound:
return true
}
Expand Down Expand Up @@ -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(ErrAPI, target)
case SessionTokenExpired, *SessionTokenExpired:
return true
}
Expand Down
2 changes: 1 addition & 1 deletion client/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,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 joinErrors(ErrAPI, err)
return err
}

return nil
Expand Down

0 comments on commit 890364b

Please sign in to comment.