generated from illuscio-dev/islelib-go
/
sentinelErrDefaults.go
50 lines (42 loc) · 1.36 KB
/
sentinelErrDefaults.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
package pkerr
import "google.golang.org/grpc/codes"
const DefaultsIssuer = "GRPEAKEC"
// sentinelIssuer is the default generator we are going to use to make our errors.
var sentinelIssuer = NewSentinelIssuer(
DefaultsIssuer,
true,
)
// ErrUnknown is the default fallback error that is returned from a server interceptor
// when an incoming error is not an APIError, *Error, or SentinelError value.
var ErrUnknown = sentinelIssuer.NewSentinel(
"Unknown",
1000,
codes.Unknown,
"an unknown error occurred",
)
// ErrNotFound is the default error for requesting a resource that does not exist.
var ErrNotFound = sentinelIssuer.NewSentinel(
"ResourceExists",
1001,
codes.NotFound,
"requested resource not found",
)
// ErrAlreadyExists is the default error for requesting a resource that already exists.
var ErrAlreadyExists = sentinelIssuer.NewSentinel(
"AlreadyExists",
1002,
codes.AlreadyExists,
"resource already exists",
)
// ErrValidation should be returned when a request fails validation.
var ErrValidation = sentinelIssuer.NewSentinel(
"Validation",
1003,
codes.InvalidArgument,
"client argument failed validation",
)
// ReissueDefaultSentinels applies the issuer and offset to all the default
// SentinelError values found in this package, such as ErrUnknown.
func ReissueDefaultSentinels(issuer string, offset int) {
sentinelIssuer.ApplyNewIssuer(issuer, offset)
}