xerrors

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(ctx context.Context, w http.ResponseWriter, err error)

Types

type Error

type Error struct {
	StatusCode int
	Message    string
	Cause      error
	RateLimit  *RateLimitInfo
	Validation *ValidationInfo
}

func As

func As(err error) *Error

func BadRequest

func BadRequest(opts ...Option) *Error

func Forbidden

func Forbidden(opts ...Option) *Error

func Internal

func Internal(opts ...Option) *Error

func NotFound

func NotFound(opts ...Option) *Error

func ServiceUnavailable

func ServiceUnavailable(opts ...Option) *Error

func TooManyRequests

func TooManyRequests(opts ...Option) *Error

func Unauthorized

func Unauthorized(opts ...Option) *Error

func Validation

func Validation(fields map[string]string, opts ...Option) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Option

type Option func(*Error)

func WithCause

func WithCause(err error) Option

func WithMessage

func WithMessage(msg string) Option

func WithReason

func WithReason(reason string) Option

func WithRetryAfter

func WithRetryAfter(d time.Duration) Option

type RateLimitInfo

type RateLimitInfo struct {
	RetryAfter time.Duration
	Reason     string
}

type ValidationInfo

type ValidationInfo struct {
	Fields map[string]string
}

Jump to

Keyboard shortcuts

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