forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_bucket.go
73 lines (62 loc) · 1.72 KB
/
error_bucket.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package tenant
import (
"fmt"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
)
var (
invalidBucketListRequest = &errors.Error{
Code: errors.EInternal,
Msg: "invalid bucket list action, call should be GetBucketByName",
Op: "kv/listBucket",
}
errRenameSystemBucket = &errors.Error{
Code: errors.EInvalid,
Msg: "system buckets cannot be renamed",
}
errDeleteSystemBucket = &errors.Error{
Code: errors.EInvalid,
Msg: "system buckets cannot be deleted",
}
ErrBucketNotFound = &errors.Error{
Code: errors.ENotFound,
Msg: "bucket not found",
}
ErrBucketNameNotUnique = &errors.Error{
Code: errors.EConflict,
Msg: "bucket name is not unique",
}
)
// ErrBucketNotFoundByName is used when the user is not found.
func ErrBucketNotFoundByName(n string) *errors.Error {
return &errors.Error{
Msg: fmt.Sprintf("bucket %q not found", n),
Code: errors.ENotFound,
}
}
// ErrCorruptBucket is used when the user cannot be unmarshalled from the bytes
// stored in the kv.
func ErrCorruptBucket(err error) *errors.Error {
return &errors.Error{
Code: errors.EInternal,
Msg: "user could not be unmarshalled",
Err: err,
Op: "kv/UnmarshalBucket",
}
}
// BucketAlreadyExistsError is used when attempting to create a user with a name
// that already exists.
func BucketAlreadyExistsError(n string) *errors.Error {
return &errors.Error{
Code: errors.EConflict,
Msg: fmt.Sprintf("bucket with name %s already exists", n),
}
}
// ErrUnprocessableBucket is used when a org is not able to be processed.
func ErrUnprocessableBucket(err error) *errors.Error {
return &errors.Error{
Code: errors.EUnprocessableEntity,
Msg: "user could not be marshalled",
Err: err,
Op: "kv/MarshalBucket",
}
}