forked from TrueCloudLab/frostfs-api-go
service: change constant errors
This commit: * moves defined errors to a separate file; * renames ErrEmptyToken to ErrNilToken; * merges ErrZeroTTL and ErrIncorrectTTL into single ErrInvalidTTL.
This commit is contained in:
parent
e3cab218dc
commit
fc177c4ce3
6 changed files with 31 additions and 37 deletions
|
@ -1,7 +1,6 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/internal"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -63,14 +62,6 @@ const (
|
|||
SingleForwardingTTL
|
||||
)
|
||||
|
||||
const (
|
||||
// ErrZeroTTL is raised when zero ttl is passed.
|
||||
ErrZeroTTL = internal.Error("zero ttl")
|
||||
|
||||
// ErrIncorrectTTL is raised when NonForwardingTTL is passed and NodeRole != InnerRingNode.
|
||||
ErrIncorrectTTL = internal.Error("incorrect ttl")
|
||||
)
|
||||
|
||||
// SetVersion sets protocol version to ResponseMetaHeader.
|
||||
func (m *ResponseMetaHeader) SetVersion(v uint32) { m.Version = v }
|
||||
|
||||
|
@ -105,7 +96,7 @@ func (m *RequestMetaHeader) RestoreMeta(v RequestMetaHeader) { *m = v }
|
|||
func IRNonForwarding(role NodeRole) TTLCondition {
|
||||
return func(ttl uint32) error {
|
||||
if ttl == NonForwardingTTL && role != InnerRingNode {
|
||||
return ErrIncorrectTTL
|
||||
return ErrInvalidTTL
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -117,7 +108,7 @@ func ProcessRequestTTL(req MetaHeader, cond ...TTLCondition) error {
|
|||
ttl := req.GetTTL()
|
||||
|
||||
if ttl == ZeroTTL {
|
||||
return status.New(codes.InvalidArgument, ErrZeroTTL.Error()).Err()
|
||||
return status.New(codes.InvalidArgument, ErrInvalidTTL.Error()).Err()
|
||||
}
|
||||
|
||||
for i := range cond {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue