aerror

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type Code

type Code string
const (
	CodeUnknown               Code = "unknown"
	CodeUnauthorized          Code = "unauthorized"
	CodeForbidden             Code = "forbidden"
	CodeNotFound              Code = "not_found"
	CodeAlreadyExists         Code = "already_exists"
	CodeConflict              Code = "conflict"
	CodeGone                  Code = "gone"
	CodeInvalid               Code = "invalid"
	CodeServerTimeout         Code = "server_timeout"
	CodeTimeout               Code = "timeout"
	CodeTooManyRequests       Code = "too_many_requests"
	CodeBadRequest            Code = "bad_request"
	CodeMethodNotAllowed      Code = "method_not_allowed"
	CodeNotAcceptable         Code = "not_acceptable"
	CodeRequestEntityTooLarge Code = "request_entity_too_large"
	CodeUnsupportedMediaType  Code = "unsupported_media_type"
	CodeInternalError         Code = "internal_error"
	CodeExpired               Code = "expired"
	CodeServiceUnavailable    Code = "service_unavailable"
)

type Details

type Details map[string]interface{}

type Error

type Error struct {
	Err            errorPayload `json:"error,omitempty"`
	HTTPStatusCode int          `json:"-"`
}

func ErrAlreadyExists

func ErrAlreadyExists(messages ...string) *Error

func ErrBadRequest

func ErrBadRequest(messages ...string) *Error

func ErrConflict

func ErrConflict(messages ...string) *Error

func ErrExpired

func ErrExpired(messages ...string) *Error

func ErrForbidden

func ErrForbidden(messages ...string) *Error

func ErrGone

func ErrGone(messages ...string) *Error

func ErrInternalError

func ErrInternalError(messages ...string) *Error

func ErrInvalid

func ErrInvalid(messages ...string) *Error

func ErrMethodNotAllowed

func ErrMethodNotAllowed(messages ...string) *Error

func ErrNotAcceptable

func ErrNotAcceptable(messages ...string) *Error

func ErrNotFound

func ErrNotFound(messages ...string) *Error

func ErrRequestEntityTooLarge

func ErrRequestEntityTooLarge(messages ...string) *Error

func ErrServerTimeout

func ErrServerTimeout(messages ...string) *Error

func ErrServiceUnavailable

func ErrServiceUnavailable(messages ...string) *Error

func ErrTimeout

func ErrTimeout(messages ...string) *Error

func ErrTooManyRequests

func ErrTooManyRequests(messages ...string) *Error

func ErrUnauthorized

func ErrUnauthorized(messages ...string) *Error

func ErrUnknown

func ErrUnknown(messages ...string) *Error

func ErrUnsupportedMediaType

func ErrUnsupportedMediaType(messages ...string) *Error

func New

func New(code Code) *Error

func NewWithAll

func NewWithAll(code Code, message string, details Details, httpStatusCode int) *Error

func UnmarshallJSON

func UnmarshallJSON(data []byte) (*Error, bool)

func (*Error) Error

func (ae *Error) Error() string

func (*Error) WithDetails

func (ae *Error) WithDetails(details Details) *Error

func (*Error) WithError

func (ae *Error) WithError(err error) *Error

func (*Error) WithHttpStatusCode

func (ae *Error) WithHttpStatusCode(statusCode int) *Error

func (*Error) WithMessage

func (ae *Error) WithMessage(message string) *Error

func (*Error) WithMessagef

func (ae *Error) WithMessagef(format string, a ...interface{}) *Error

func (*Error) WithMessages

func (ae *Error) WithMessages(messages ...string) *Error

Jump to

Keyboard shortcuts

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