errors

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValidation = NewBadRequestError(New("validation failed"))
	ErrBadRequest = NewBadRequestError(New("bad request"))
	ErrNotFound   = NewNotFoundError(New("not found"))
	ErrInternal   = NewStatusInternalServerError(New("internal error"))
)

Service errors.

Functions

func New

func New(text string) error

New returns an error that formats as the given text.

func StatusCodeFromError

func StatusCodeFromError(e error) int

StatusCodeFromError returns status code if an error implements an interface.

Types

type StatusErr

type StatusErr struct {
	// contains filtered or unexported fields
}

StatusErr an error with status code.

func NewBadRequestError

func NewBadRequestError(err error) *StatusErr

NewBadRequestError represents BadRequest error.

func NewNotFoundError

func NewNotFoundError(err error) *StatusErr

NewNotFoundError represents NotFound error.

func NewStatusInternalServerError

func NewStatusInternalServerError(err error) *StatusErr

NewStatusInternalServerError represents InternalServerError.

func (*StatusErr) StatusCode

func (e *StatusErr) StatusCode() int

StatusCode returns HTTP status code.

func (*StatusErr) Unwrap

func (e *StatusErr) Unwrap() error

Unwrap returns the result of calling the Unwrap method on err.

Jump to

Keyboard shortcuts

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