influxdb/meta/errors.go

127 lines
4.5 KiB
Go
Raw Normal View History

2015-05-21 20:06:01 +00:00
package meta
import (
"errors"
"fmt"
)
2015-05-21 20:06:01 +00:00
var (
// ErrStoreOpen is returned when opening an already open store.
2015-09-30 04:52:52 +00:00
ErrStoreOpen = newError("store already open")
2015-05-21 20:06:01 +00:00
// ErrStoreClosed is returned when closing an already closed store.
2015-09-30 04:52:52 +00:00
ErrStoreClosed = newError("raft store already closed")
// ErrTooManyPeers is returned when more than 3 peers are used.
2015-09-30 04:52:52 +00:00
ErrTooManyPeers = newError("too many peers; influxdb v0.9.0 is limited to 3 nodes in a cluster")
2015-05-21 20:06:01 +00:00
)
var (
// ErrNodeExists is returned when creating an already existing node.
2015-09-30 04:52:52 +00:00
ErrNodeExists = newError("node already exists")
2015-05-21 20:06:01 +00:00
// ErrNodeNotFound is returned when mutating a node that doesn't exist.
2015-09-30 04:52:52 +00:00
ErrNodeNotFound = newError("node not found")
2015-05-21 20:06:01 +00:00
// ErrNodesRequired is returned when at least one node is required for an operation.
// This occurs when creating a shard group.
2015-09-30 04:52:52 +00:00
ErrNodesRequired = newError("at least one node required")
2015-10-03 02:49:11 +00:00
// ErrNodeIDRequired is returned when using a zero node id.
ErrNodeIDRequired = newError("node id must be greater than 0")
2015-11-07 06:54:23 +00:00
// ErrNodeUnableToDropFinalNode is returned if the node being dropped is the last
2015-10-03 02:49:11 +00:00
// node in the cluster
ErrNodeUnableToDropFinalNode = newError("unable to drop the final node in a cluster")
2015-05-21 20:06:01 +00:00
)
var (
// ErrDatabaseExists is returned when creating an already existing database.
2015-09-30 04:52:52 +00:00
ErrDatabaseExists = newError("database already exists")
2015-05-21 20:06:01 +00:00
// ErrDatabaseNameRequired is returned when creating a database without a name.
2015-09-30 04:52:52 +00:00
ErrDatabaseNameRequired = newError("database name required")
2015-05-21 20:06:01 +00:00
)
var (
// ErrRetentionPolicyExists is returned when creating an already existing policy.
2015-09-30 04:52:52 +00:00
ErrRetentionPolicyExists = newError("retention policy already exists")
2015-05-21 20:06:01 +00:00
// ErrRetentionPolicyDefault is returned when attempting a prohibited operation
// on a default retention policy.
2015-09-30 04:52:52 +00:00
ErrRetentionPolicyDefault = newError("retention policy is default")
2015-05-21 20:06:01 +00:00
// ErrRetentionPolicyNameRequired is returned when creating a policy without a name.
2015-09-30 04:52:52 +00:00
ErrRetentionPolicyNameRequired = newError("retention policy name required")
2015-05-21 20:06:01 +00:00
// ErrRetentionPolicyNameExists is returned when renaming a policy to
// the same name as another existing policy.
2015-09-30 04:52:52 +00:00
ErrRetentionPolicyNameExists = newError("retention policy name already exists")
2015-05-27 19:41:58 +00:00
// ErrRetentionPolicyDurationTooLow is returned when updating a retention
// policy that has a duration lower than the allowed minimum.
2015-09-30 04:52:52 +00:00
ErrRetentionPolicyDurationTooLow = newError(fmt.Sprintf("retention policy duration must be at least %s",
MinRetentionPolicyDuration))
// ErrReplicationFactorTooLow is returned when the replication factor is not in an
// acceptable range.
2015-09-30 04:52:52 +00:00
ErrReplicationFactorTooLow = newError("replication factor must be greater than 0")
2015-05-21 20:06:01 +00:00
)
var (
// ErrShardGroupExists is returned when creating an already existing shard group.
2015-09-30 04:52:52 +00:00
ErrShardGroupExists = newError("shard group already exists")
2015-05-21 20:06:01 +00:00
// ErrShardGroupNotFound is returned when mutating a shard group that doesn't exist.
2015-09-30 04:52:52 +00:00
ErrShardGroupNotFound = newError("shard group not found")
2015-10-03 02:49:11 +00:00
// ErrShardNotReplicated is returned if the node requested to be dropped has
// the last copy of a shard present and the force keyword was not used
ErrShardNotReplicated = newError("shard not replicated")
2015-05-21 20:06:01 +00:00
)
var (
// ErrContinuousQueryExists is returned when creating an already existing continuous query.
2015-09-30 04:52:52 +00:00
ErrContinuousQueryExists = newError("continuous query already exists")
2015-05-21 20:06:01 +00:00
// ErrContinuousQueryNotFound is returned when removing a continuous query that doesn't exist.
2015-09-30 04:52:52 +00:00
ErrContinuousQueryNotFound = newError("continuous query not found")
2015-05-21 20:06:01 +00:00
)
var (
// ErrSubscriptionExists is returned when creating an already existing subscription.
ErrSubscriptionExists = newError("subscription already exists")
// ErrSubscriptionNotFound is returned when removing a subscription that doesn't exist.
ErrSubscriptionNotFound = newError("subscription not found")
)
2015-05-21 20:06:01 +00:00
var (
// ErrUserExists is returned when creating an already existing user.
2015-09-30 04:52:52 +00:00
ErrUserExists = newError("user already exists")
2015-05-21 20:06:01 +00:00
// ErrUserNotFound is returned when mutating a user that doesn't exist.
2015-09-30 04:52:52 +00:00
ErrUserNotFound = newError("user not found")
2015-05-21 20:06:01 +00:00
// ErrUsernameRequired is returned when creating a user without a username.
2015-09-30 04:52:52 +00:00
ErrUsernameRequired = newError("username required")
2015-05-21 20:06:01 +00:00
)
// errLookup stores a mapping of error strings to well defined error types.
var errLookup = make(map[string]error)
2015-09-30 04:52:52 +00:00
func newError(msg string) error {
err := errors.New(msg)
errLookup[err.Error()] = err
return err
2015-05-21 20:06:01 +00:00
}
// lookupError returns a known error reference, if one exists.
// Otherwise returns err.
func lookupError(err error) error {
if e, ok := errLookup[err.Error()]; ok {
return e
}
return err
}