-
Notifications
You must be signed in to change notification settings - Fork 247
/
errors.go
37 lines (31 loc) · 1.04 KB
/
errors.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
package memdb
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/spicedb/pkg/spiceerrors"
)
// ErrSerializationMaxRetriesReached occurs when a write request has reached its maximum number
// of retries due to serialization errors.
type ErrSerializationMaxRetriesReached struct {
error
}
// NewSerializationMaxRetriesReachedErr constructs a new max retries reached error.
func NewSerializationMaxRetriesReachedErr(baseErr error) error {
return ErrSerializationMaxRetriesReached{
error: baseErr,
}
}
// GRPCStatus implements retrieving the gRPC status for the error.
func (err ErrSerializationMaxRetriesReached) GRPCStatus() *status.Status {
return spiceerrors.WithCodeAndDetails(
err,
codes.DeadlineExceeded,
spiceerrors.ForReason(
v1.ErrorReason_ERROR_REASON_UNSPECIFIED,
map[string]string{
"details": "too many updates were made to the in-memory datastore at once; this datastore has limited write throughput capability",
},
),
)
}