forked from TrueCloudLab/frostfs-sdk-go
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:
parent
a4e14ab35b
commit
e0afe0807c
5 changed files with 21 additions and 19 deletions
|
@ -45,7 +45,7 @@ func (x ServerInternal) Error() string {
|
||||||
func (x ServerInternal) Is(target error) bool {
|
func (x ServerInternal) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ServerInternal, *ServerInternal:
|
case ServerInternal, *ServerInternal:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func (x WrongMagicNumber) Error() string {
|
||||||
func (x WrongMagicNumber) Is(target error) bool {
|
func (x WrongMagicNumber) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case WrongMagicNumber, *WrongMagicNumber:
|
case WrongMagicNumber, *WrongMagicNumber:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func (x SignatureVerification) Error() string {
|
||||||
func (x SignatureVerification) Is(target error) bool {
|
func (x SignatureVerification) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case SignatureVerification, *SignatureVerification:
|
case SignatureVerification, *SignatureVerification:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func (x NodeUnderMaintenance) Error() string {
|
||||||
func (x NodeUnderMaintenance) Is(target error) bool {
|
func (x NodeUnderMaintenance) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case NodeUnderMaintenance, *NodeUnderMaintenance:
|
case NodeUnderMaintenance, *NodeUnderMaintenance:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package apistatus
|
package apistatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
"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 {
|
func (x ContainerNotFound) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ContainerNotFound, *ContainerNotFound:
|
case ContainerNotFound, *ContainerNotFound:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -86,7 +88,7 @@ func (x EACLNotFound) Error() string {
|
||||||
func (x EACLNotFound) Is(target error) bool {
|
func (x EACLNotFound) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case EACLNotFound, *EACLNotFound:
|
case EACLNotFound, *EACLNotFound:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package apistatus
|
package apistatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
"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 {
|
func (x ObjectLocked) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ObjectLocked, *ObjectLocked:
|
case ObjectLocked, *ObjectLocked:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,7 @@ func (x LockNonRegularObject) Error() string {
|
||||||
func (x LockNonRegularObject) Is(target error) bool {
|
func (x LockNonRegularObject) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case LockNonRegularObject, *LockNonRegularObject:
|
case LockNonRegularObject, *LockNonRegularObject:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -144,7 +146,7 @@ func (x ObjectAccessDenied) Error() string {
|
||||||
func (x ObjectAccessDenied) Is(target error) bool {
|
func (x ObjectAccessDenied) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ObjectAccessDenied, *ObjectAccessDenied:
|
case ObjectAccessDenied, *ObjectAccessDenied:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,7 @@ func (x ObjectNotFound) Error() string {
|
||||||
func (x ObjectNotFound) Is(target error) bool {
|
func (x ObjectNotFound) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ObjectNotFound, *ObjectNotFound:
|
case ObjectNotFound, *ObjectNotFound:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -249,7 +251,7 @@ func (x ObjectAlreadyRemoved) Error() string {
|
||||||
func (x ObjectAlreadyRemoved) Is(target error) bool {
|
func (x ObjectAlreadyRemoved) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ObjectAlreadyRemoved, *ObjectAlreadyRemoved:
|
case ObjectAlreadyRemoved, *ObjectAlreadyRemoved:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -297,7 +299,7 @@ func (x ObjectOutOfRange) Error() string {
|
||||||
func (x ObjectOutOfRange) Is(target error) bool {
|
func (x ObjectOutOfRange) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case ObjectOutOfRange, *ObjectOutOfRange:
|
case ObjectOutOfRange, *ObjectOutOfRange:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package apistatus
|
package apistatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
"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 {
|
func (x SessionTokenNotFound) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case SessionTokenNotFound, *SessionTokenNotFound:
|
case SessionTokenNotFound, *SessionTokenNotFound:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -85,7 +87,7 @@ func (x SessionTokenExpired) Error() string {
|
||||||
func (x SessionTokenExpired) Is(target error) bool {
|
func (x SessionTokenExpired) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
return false
|
return errors.Is(Error, target)
|
||||||
case SessionTokenExpired, *SessionTokenExpired:
|
case SessionTokenExpired, *SessionTokenExpired:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package apistatus
|
package apistatus
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Status defines a variety of NeoFS API status returns.
|
// Status defines a variety of NeoFS API status returns.
|
||||||
//
|
//
|
||||||
// All statuses are split into two disjoint subsets: successful and failed, and:
|
// 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.
|
// Note: direct assignment may not be compatibility-safe.
|
||||||
func ErrFromStatus(st Status) error {
|
func ErrFromStatus(st Status) error {
|
||||||
if err, ok := st.(error); ok {
|
if err, ok := st.(error); ok {
|
||||||
return errors.Join(Error, err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue