From b257812c223ff599be62ffc245517e9b07994433 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 5 Feb 2018 13:15:06 -0800 Subject: [PATCH] move error --- nomad/structs/errors.go | 8 ++++++++ nomad/structs/streaming_rpc.go | 19 ------------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/nomad/structs/errors.go b/nomad/structs/errors.go index cdb0ab2a1..78d8fde5c 100644 --- a/nomad/structs/errors.go +++ b/nomad/structs/errors.go @@ -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) +} diff --git a/nomad/structs/streaming_rpc.go b/nomad/structs/streaming_rpc.go index 602194531..d9f9b8878 100644 --- a/nomad/structs/streaming_rpc.go +++ b/nomad/structs/streaming_rpc.go @@ -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 {