errors

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest          = New("BadRequest")
	ErrUnauthorized        = New("Unauthorized")
	ErrForbidden           = New("Forbidden")
	ErrNotFound            = New("NotFound")
	ErrConflict            = New("Conflict")
	ErrTooManyRequests     = New("TooManyRequests")
	ErrInternalServerError = New("InternalServerError")
	ErrUnexpected          = New("UnexpectedError")
	ErrGeneric             = New("GenericError")
)

Sentinel errors

Functions

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target. This function is similar to the standard errors.Is, but works with our custom Error type.

Types

type Error

type Error struct {
	OriginalError error
	UserMessage   string
}

Error wraps the original error and adds a user-friendly message

func HandleHTTPError

func HandleHTTPError(resp *http.Response) *Error

func New

func New(userMessage string) *Error

New creates a new Error with just a user message

func Wrap

func Wrap(err error, userMessage string) *Error

Wrap creates a new Error that wraps an existing error with a user-friendly message

func Wrapf

func Wrapf(err error, format string, args ...interface{}) *Error

Wrapf creates a new Error that wraps an existing error with a formatted user-friendly message

func (*Error) Error

func (e *Error) Error() string

Error returns the user-friendly message

func (*Error) Is

func (e *Error) Is(target error) bool

Is reports whether any error in err's chain matches target.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the original error

Jump to

Keyboard shortcuts

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