Skip to content

Commit

Permalink
*: use errors.ErrUnsupported where applicable
Browse files Browse the repository at this point in the history
Closes #2517.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Aug 30, 2024
1 parent fe797eb commit 2095361
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/neofs-cli/internal/common/eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package common

import (
"errors"
"fmt"
"os"

"github.com/nspcc-dev/neofs-node/pkg/core/version"
Expand All @@ -10,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

var errUnsupportedEACLFormat = errors.New("unsupported eACL format")
var errUnsupportedEACLFormat = fmt.Errorf("%w: unsupported eACL format", errors.ErrUnsupported)

// ReadEACL reads extended ACL table from eaclPath.
func ReadEACL(cmd *cobra.Command, eaclPath string) eacl.Table {
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/control/shards_set_mode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package control

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -110,7 +111,7 @@ func setShardMode(cmd *cobra.Command, _ []string) {

mode, ok := lookUpShardModeFromString(strMode)
if !ok {
common.ExitOnErr(cmd, "", fmt.Errorf("unsupported mode %s", strMode))
common.ExitOnErr(cmd, "", fmt.Errorf("%w: setting %s mode", errors.ErrUnsupported, strMode))
}

req := new(control.SetShardModeRequest)
Expand Down
5 changes: 3 additions & 2 deletions cmd/neofs-cli/modules/object/search.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package object

import (
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -116,14 +117,14 @@ func parseSearchFilters(cmd *cobra.Command) (object.SearchFilters, error) {
case 2:
m, ok := searchUnaryOpVocabulary[words[1]]
if !ok {
return nil, fmt.Errorf("unsupported unary op: %s", words[1])
return nil, fmt.Errorf("%w: unary op: %s", errors.ErrUnsupported, words[1])
}

fs.AddFilter(words[0], "", m)
case 3:
m, ok := searchBinaryOpVocabulary[words[1]]
if !ok {
return nil, fmt.Errorf("unsupported binary op: %s", words[1])
return nil, fmt.Errorf("%w: binary op: %s", errors.ErrUnsupported, words[1])
}

fs.AddFilter(words[0], words[2], m)
Expand Down
3 changes: 2 additions & 1 deletion pkg/morph/client/netmap/netmap.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netmap

import (
"errors"
"fmt"

"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
Expand Down Expand Up @@ -119,7 +120,7 @@ func decodeNodeInfo(dst *netmap.NodeInfo, itemNode stackitem.Item) error {

switch node.State.Int64() {
default:
return fmt.Errorf("unsupported state %v", node.State)
return fmt.Errorf("%w: unsupported state %v", errors.ErrUnsupported, node.State)
case netmaprpc.NodeStateOnline.Int64():
dst.SetOnline()
case netmaprpc.NodeStateOffline.Int64():
Expand Down
3 changes: 2 additions & 1 deletion pkg/morph/event/netmap/update_peer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netmap

import (
"errors"
"fmt"

"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
Expand Down Expand Up @@ -46,7 +47,7 @@ func (s UpdatePeer) NotaryRequest() *payload.P2PNotaryRequest {
func (s *UpdatePeer) decodeState(state int64) error {
switch s.state = nodestate.Type(state); s.state {
default:
return fmt.Errorf("unsupported node state %d", state)
return fmt.Errorf("%w: unsupported node state %d", errors.ErrUnsupported, state)
case
nodestate.Offline,
nodestate.Online,
Expand Down

0 comments on commit 2095361

Please sign in to comment.