Documentation
¶
Index ¶
- func Aborted(format string, args ...any) error
- func Conflict(format string, args ...any) error
- func ConnectErrorComparer() cmp.Option
- func Convert(err error) *connect.Error
- func ErrorStringComparer() cmp.Option
- func FailedPrecondition(format string, args ...any) error
- func Internal(format string, args ...any) error
- func InvalidArgument(format string, args ...any) error
- func IsAborted(err error) bool
- func IsConflict(err error) bool
- func IsFailedPrecondition(err error) bool
- func IsInternal(err error) bool
- func IsInvalidArgument(err error) bool
- func IsNotFound(err error) bool
- func IsPermissionDenied(err error) bool
- func IsResourceExhausted(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnimplemented(err error) bool
- func NewAborted(err error) error
- func NewConflict(err error) error
- func NewFailedPrecondition(err error) error
- func NewInternal(err error) error
- func NewInvalidArgument(err error) error
- func NewNotFound(err error) error
- func NewPermissionDenied(err error) error
- func NewResourceExhausted(err error) error
- func NewUnauthenticated(err error) error
- func NewUnimplemented(err error) error
- func NotFound(format string, args ...any) error
- func PermissionDenied(format string, args ...any) error
- func ResourceExhausted(format string, args ...any) error
- func Unauthenticated(format string, args ...any) error
- func Unimplemented(format string, args ...any) error
- func UpstreamValidation(domain, op string, errs []ValidationError) *connect.Error
- func WrapConnectErr(c connect.Code, underlying error) *connect.Error
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aborted ¶
Aborted creates a new Aborted error (Connect Code 10) with a formatted error message.
func Conflict ¶
Conflict creates a new Already Exists error (Connect Code 6) with a formatted error message.
func ConnectErrorComparer ¶
ConnectErrorComparer returns a go-cmp Option for comparing *connect.Error values. Two errors are considered equal if they have the same error string and the same Connect code.
func Convert ¶
Convert compares the error and maps it to an appropriate connect.Error. If there is no backend-specific wrapped error given to this function, it will return an internal error. If there are multiple errors wrapped, this function only cares about the first found error in the error tree.
func ErrorStringComparer ¶
ErrorStringComparer returns a go-cmp Option for comparing error values. Two errors are considered equal if their Error() strings are identical.
func FailedPrecondition ¶
FailedPrecondition creates a new Failed Precondition error (Connect Code 9) with a formatted error message.
func Internal ¶
Internal creates a new Internal error (Connect Code 13) with a formatted error message.
func InvalidArgument ¶
InvalidArgument creates a new Invalid Argument error (Connect Code 3) with a formatted error message.
func IsConflict ¶
IsConflict reports whether the error is an Already Exists error (Connect Code 6).
func IsFailedPrecondition ¶
IsFailedPrecondition reports whether the error is a Failed Precondition error (Connect Code 9).
func IsInternal ¶
IsInternal reports whether the error is an Internal error (Connect Code 13).
func IsInvalidArgument ¶
IsInvalidArgument reports whether the error is an Invalid Argument error (Connect Code 3).
func IsNotFound ¶
IsNotFound reports whether the error is a Not Found error (Connect Code 5).
func IsPermissionDenied ¶
IsPermissionDenied reports whether the error is a Permission Denied error (Connect Code 7).
func IsResourceExhausted ¶
IsResourceExhausted reports whether the error is a Resource Exhausted error (Connect Code 8).
func IsUnauthenticated ¶
IsUnauthenticated reports whether the error is an Unauthenticated error (Connect Code 16).
func IsUnimplemented ¶
IsUnimplemented reports whether the error is an Unimplemented error (Connect Code 12).
func NewAborted ¶
NewAborted creates a new Aborted error (Connect Code 10) from an underlying error.
func NewConflict ¶
NewConflict creates a new Already Exists error (Connect Code 6) from an underlying error.
func NewFailedPrecondition ¶
NewFailedPrecondition creates a new Failed Precondition error (Connect Code 9) from an underlying error.
func NewInternal ¶
NewInternal creates a new Internal error (Connect Code 13) from an underlying error.
func NewInvalidArgument ¶
NewInvalidArgument creates a new Invalid Argument error (Connect Code 3) from an underlying error.
func NewNotFound ¶
NewNotFound creates a new Not Found error (Connect Code 5) from an underlying error.
func NewPermissionDenied ¶
NewPermissionDenied creates a new Permission Denied error (Connect Code 7) from an underlying error.
func NewResourceExhausted ¶
NewResourceExhausted creates a new Resource Exhausted error (Connect Code 8) from an underlying error.
func NewUnauthenticated ¶
NewUnauthenticated creates a new Unauthenticated error (Connect Code 16) from an underlying error.
func NewUnimplemented ¶
NewUnimplemented creates a new Unimplemented error (Connect Code 12) from an underlying error.
func NotFound ¶
NotFound creates a new Not Found error (Connect Code 5) with a formatted error message.
func PermissionDenied ¶
PermissionDenied creates a new Permission Denied error (Connect Code 7) with a formatted error message.
func ResourceExhausted ¶
ResourceExhausted creates a new Resource Exhausted error (Connect Code 8) with a formatted error message.
func Unauthenticated ¶
Unauthenticated creates a new Unauthenticated error (Connect Code 16) with a formatted error message.
func Unimplemented ¶
Unimplemented creates a new Unimplemented error (Connect Code 12) with a formatted error message.
func UpstreamValidation ¶
func UpstreamValidation(domain, op string, errs []ValidationError) *connect.Error
UpstreamValidation builds an InvalidArgument connect.Error for upstream validation rejections (HTTP 422). It attaches the standard google.rpc error details so clients can render per-field problems uniformly:
- BadRequest with one FieldViolation per error (field = dotted loc path, description = upstream message)
- ErrorInfo identifying the upstream domain and the error type
The top-level message stays generic; the structured content lives in the details. This mirrors how buf.validate failures surface locally, so clients see one uniform shape for "your input was wrong" regardless of which layer rejected it.
Types ¶
type ValidationError ¶
type ValidationError struct {
// Loc is the path of the offending field within the upstream request,
// e.g. ["body", "serviceclass"].
Loc []string
// Msg is a human readable description of the problem.
Msg string
// Type is the upstream error type, e.g. "value_error".
Type string
}
ValidationError describes a single validation problem reported by an upstream API (e.g. an HTTP 422 body from nulink).