errx

package
v1.13.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Is = errors.Is
	As = errors.As
)

Functions

This section is empty.

Types

type Error added in v1.9.0

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message,omitempty"`

	Metadata map[string]any `json:"metadata,omitempty"`
	// contains filtered or unexported fields
}
var (
	OK = New(0, "ok").WithStatusCode(http.StatusOK)

	ErrInternal = New(statusCodeBegin, "Internal Error").WithStatusCode(http.StatusInternalServerError)

	ErrParam     *Error
	ErrUnAuth    *Error
	ErrForbidden *Error
	ErrNotFound  *Error
	ErrNoMethod  *Error
	ErrConflict  *Error
)

func From added in v1.9.0

func From(err error) *Error

func FromStatusCode added in v1.9.0

func FromStatusCode(statusCode int) *Error

func New

func New(code int, s string, v ...any) *Error

func (*Error) AppendMetadata added in v1.9.0

func (e *Error) AppendMetadata(kvs ...any) *Error

func (*Error) Copy added in v1.9.0

func (e *Error) Copy() *Error

func (*Error) Error added in v1.9.0

func (e *Error) Error() (s string)

func (*Error) StatusCode added in v1.9.0

func (e *Error) StatusCode() int

func (*Error) WithMessage added in v1.9.0

func (e *Error) WithMessage(s string, v ...any) *Error

func (*Error) WithMetadata added in v1.9.0

func (e *Error) WithMetadata(kvs ...any) *Error

func (*Error) WithStatusCode added in v1.9.0

func (e *Error) WithStatusCode(statusCode int) *Error

Jump to

Keyboard shortcuts

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