Documentation
¶
Index ¶
- Variables
- func IgnoreAlreadyExists(err error) error
- func IgnoreNotFound(err error) error
- func MustHandle(err error, handlers ...func(error) error)
- type CategoryMatcher
- type CodeMatcher
- type ErrorAction
- type ErrorCategory
- type ErrorDetails
- type ErrorHandler
- func (h *ErrorHandler) Fallback(handler func(error) error) *ErrorHandler
- func (h *ErrorHandler) Handle(err error) error
- func (h *ErrorHandler) On(code codes.Code, handler func(error) error) *ErrorHandler
- func (h *ErrorHandler) OnAuth(handler func(error) error) *ErrorHandler
- func (h *ErrorHandler) OnNetwork(handler func(error) error) *ErrorHandler
- func (h *ErrorHandler) OnNotFound(handler func(error) error) *ErrorHandler
- type ErrorMatcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AuthErrors = NewCodeMatcher(codes.Unauthenticated, codes.PermissionDenied) NetworkErrors = NewCodeMatcher(codes.Unavailable, codes.DeadlineExceeded, codes.Canceled) ServerErrors = NewCodeMatcher(codes.Internal, codes.Unknown, codes.DataLoss, codes.Unimplemented) ValidationErrors = NewCodeMatcher(codes.InvalidArgument, codes.FailedPrecondition, codes.OutOfRange) ResourceErrors = NewCodeMatcher(codes.NotFound, codes.AlreadyExists) RetryableErrors = NewCodeMatcher(codes.Unavailable, codes.ResourceExhausted, codes.Aborted, codes.DeadlineExceeded) )
Functions ¶
func IgnoreAlreadyExists ¶
func IgnoreNotFound ¶
func MustHandle ¶
Types ¶
type CategoryMatcher ¶
type CategoryMatcher struct {
// contains filtered or unexported fields
}
func NewCategoryMatcher ¶
func NewCategoryMatcher(c ...ErrorCategory) *CategoryMatcher
func (*CategoryMatcher) Match ¶
func (m *CategoryMatcher) Match(err error) bool
type CodeMatcher ¶
type CodeMatcher struct {
// contains filtered or unexported fields
}
func NewCodeMatcher ¶
func NewCodeMatcher(c ...codes.Code) *CodeMatcher
func (*CodeMatcher) Match ¶
func (m *CodeMatcher) Match(err error) bool
type ErrorAction ¶
type ErrorAction int
const ( ActionNone ErrorAction = iota ActionRetry ActionReauth ActionForbidden ActionNotFound ActionBadRequest ActionRateLimit ActionFailover ActionEscalate )
func (ErrorAction) String ¶
func (a ErrorAction) String() string
type ErrorCategory ¶
type ErrorCategory int
const ( CategoryUnknown ErrorCategory = iota CategoryClient CategoryServer CategoryNetwork CategoryAuth CategoryValidation CategoryRateLimit )
func (ErrorCategory) String ¶
func (c ErrorCategory) String() string
type ErrorDetails ¶
type ErrorDetails struct {
Code string
GRPCCode codes.Code
Message string
Category ErrorCategory
IsRetryable bool
IsClientError bool
IsServerError bool
SuggestedAction ErrorAction
RetryAfter time.Duration
}
func Analyze ¶
func Analyze(err error) *ErrorDetails
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
func NewErrorHandler ¶
func NewErrorHandler() *ErrorHandler
func (*ErrorHandler) Fallback ¶
func (h *ErrorHandler) Fallback(handler func(error) error) *ErrorHandler
func (*ErrorHandler) Handle ¶
func (h *ErrorHandler) Handle(err error) error
func (*ErrorHandler) On ¶
func (h *ErrorHandler) On(code codes.Code, handler func(error) error) *ErrorHandler
func (*ErrorHandler) OnAuth ¶
func (h *ErrorHandler) OnAuth(handler func(error) error) *ErrorHandler
func (*ErrorHandler) OnNetwork ¶
func (h *ErrorHandler) OnNetwork(handler func(error) error) *ErrorHandler
func (*ErrorHandler) OnNotFound ¶
func (h *ErrorHandler) OnNotFound(handler func(error) error) *ErrorHandler
type ErrorMatcher ¶
Click to show internal directories.
Click to hide internal directories.