errors

package
v0.0.0-...-c9ce307 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest          = New(http.StatusBadRequest)
	ErrUnauthorized        = New(http.StatusUnauthorized)
	ErrForbidden           = New(http.StatusForbidden)
	ErrNotFound            = New(http.StatusNotFound)
	ErrInternalServerError = New(http.StatusInternalServerError)
	ErrBadGateway          = New(http.StatusBadGateway)
)

Functions

This section is empty.

Types

type Code

type Code uint32
const (
	BadRequest Code = iota + 4000
	RateLimitExceeded
	MissingIdentifier
	AttachmentSizeExceeded
	MaxNumberOfUsersReached
	BadUsername
	WrongPassword
)

Client error codes

const (
	CodeInternalError Code = iota + 5000
)

Server error codes

type ErrorOption

type ErrorOption func(e *HTTPError)

func WithError

func WithError(err error) ErrorOption

func WithErrorf

func WithErrorf(format string, a ...any) ErrorOption

type HTTPError

type HTTPError struct {
	Status  int    `json:"-"`
	Message string `json:"message"`
	Code    Code   `json:"code,omitempty"`
	// contains filtered or unexported fields
}

func From

func From(code Code) *HTTPError

From creates a new HTTPError from a specific error code.

func New

func New(status int, message ...string) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (HTTPError) Is

func (e HTTPError) Is(err error) bool

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

func (HTTPError) Wrap

func (e HTTPError) Wrap(options ...ErrorOption) error

Jump to

Keyboard shortcuts

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