move error

This commit is contained in:
Alex Dadgar
2018-02-05 13:15:06 -08:00
parent d77b36698c
commit b257812c22
2 changed files with 8 additions and 19 deletions

View File

@@ -11,6 +11,7 @@ const (
errTokenNotFound = "ACL token not found"
errPermissionDenied = "Permission denied"
errNoNodeConn = "No path to node"
errUnknownMethod = "unknown rpc method"
)
var (
@@ -19,6 +20,7 @@ var (
ErrTokenNotFound = errors.New(errTokenNotFound)
ErrPermissionDenied = errors.New(errPermissionDenied)
ErrNoNodeConn = errors.New(errNoNodeConn)
ErrUnknownMethod = errors.New(errUnknownMethod)
)
// IsErrNoLeader returns whether the error is due to there being no leader.
@@ -49,3 +51,9 @@ func IsErrPermissionDenied(err error) bool {
func IsErrNoNodeConn(err error) bool {
return err != nil && strings.Contains(err.Error(), errNoNodeConn)
}
// IsErrUnknownMethod returns whether the error is due to the operation not
// being allowed due to lack of permissions.
func IsErrUnknownMethod(err error) bool {
return err != nil && strings.Contains(err.Error(), errUnknownMethod)
}

View File

@@ -1,29 +1,10 @@
package structs
import (
"errors"
"io"
"strings"
"sync"
)
// TODO(alexdadgar): move to errors.go
const (
errUnknownMethod = "unknown rpc method"
)
var (
// ErrUnknownMethod is used to indicate that the requested method
// is unknown.
ErrUnknownMethod = errors.New(errUnknownMethod)
)
// IsErrUnknownMethod returns whether the error is due to the operation not
// being allowed due to lack of permissions.
func IsErrUnknownMethod(err error) bool {
return err != nil && strings.Contains(err.Error(), errUnknownMethod)
}
// StreamingRpcHeader is the first struct serialized after entering the
// streaming RPC mode. The header is used to dispatch to the correct method.
type StreamingRpcHeader struct {