errorutil

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aborted

func Aborted(format string, args ...any) error

Aborted creates a new Aborted error (Connect Code 10) with a formatted error message.

func Conflict

func Conflict(format string, args ...any) error

Conflict creates a new Already Exists error (Connect Code 6) with a formatted error message.

func ConnectErrorComparer

func ConnectErrorComparer() cmp.Option

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

func Convert(err error) *connect.Error

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

func ErrorStringComparer() cmp.Option

ErrorStringComparer returns a go-cmp Option for comparing error values. Two errors are considered equal if their Error() strings are identical.

func FailedPrecondition

func FailedPrecondition(format string, args ...any) error

FailedPrecondition creates a new Failed Precondition error (Connect Code 9) with a formatted error message.

func Internal

func Internal(format string, args ...any) error

Internal creates a new Internal error (Connect Code 13) with a formatted error message.

func InvalidArgument

func InvalidArgument(format string, args ...any) error

InvalidArgument creates a new Invalid Argument error (Connect Code 3) with a formatted error message.

func IsAborted

func IsAborted(err error) bool

IsAborted reports whether the error is an Aborted error (Connect Code 10).

func IsConflict

func IsConflict(err error) bool

IsConflict reports whether the error is an Already Exists error (Connect Code 6).

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

IsFailedPrecondition reports whether the error is a Failed Precondition error (Connect Code 9).

func IsInternal

func IsInternal(err error) bool

IsInternal reports whether the error is an Internal error (Connect Code 13).

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument reports whether the error is an Invalid Argument error (Connect Code 3).

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether the error is a Not Found error (Connect Code 5).

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied reports whether the error is a Permission Denied error (Connect Code 7).

func IsResourceExhausted

func IsResourceExhausted(err error) bool

IsResourceExhausted reports whether the error is a Resource Exhausted error (Connect Code 8).

func IsUnauthenticated

func IsUnauthenticated(err error) bool

IsUnauthenticated reports whether the error is an Unauthenticated error (Connect Code 16).

func NewAborted

func NewAborted(err error) error

NewAborted creates a new Aborted error (Connect Code 10) from an underlying error.

func NewConflict

func NewConflict(err error) error

NewConflict creates a new Already Exists error (Connect Code 6) from an underlying error.

func NewFailedPrecondition

func NewFailedPrecondition(err error) error

NewFailedPrecondition creates a new Failed Precondition error (Connect Code 9) from an underlying error.

func NewInternal

func NewInternal(err error) error

NewInternal creates a new Internal error (Connect Code 13) from an underlying error.

func NewInvalidArgument

func NewInvalidArgument(err error) error

NewInvalidArgument creates a new Invalid Argument error (Connect Code 3) from an underlying error.

func NewNotFound

func NewNotFound(err error) error

NewNotFound creates a new Not Found error (Connect Code 5) from an underlying error.

func NewPermissionDenied

func NewPermissionDenied(err error) error

NewPermissionDenied creates a new Permission Denied error (Connect Code 7) from an underlying error.

func NewResourceExhausted

func NewResourceExhausted(err error) error

NewResourceExhausted creates a new Resource Exhausted error (Connect Code 8) from an underlying error.

func NewUnauthenticated

func NewUnauthenticated(err error) error

NewUnauthenticated creates a new Unauthenticated error (Connect Code 16) from an underlying error.

func NotFound

func NotFound(format string, args ...any) error

NotFound creates a new Not Found error (Connect Code 5) with a formatted error message.

func PermissionDenied

func PermissionDenied(format string, args ...any) error

PermissionDenied creates a new Permission Denied error (Connect Code 7) with a formatted error message.

func ResourceExhausted

func ResourceExhausted(format string, args ...any) error

ResourceExhausted creates a new Resource Exhausted error (Connect Code 8) with a formatted error message.

func Unauthenticated

func Unauthenticated(format string, args ...any) error

Unauthenticated creates a new Unauthenticated error (Connect Code 16) with a formatted error message.

func WrapConnectErr

func WrapConnectErr(c connect.Code, underlying error) *connect.Error

WrapConnectErr wraps the error into a connect.Error with the given code if it is not already a connect.Error. If the error is already a *connect.Error, it returns it unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL