errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 4 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 the func supports rpc errors as well.

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 BadRequestError.

func NewNotFoundError

func NewNotFoundError(err error) *StatusErr

NewNotFoundError represents NotFoundError.

func NewStatusInternalServerError

func NewStatusInternalServerError(err error) *StatusErr

NewStatusInternalServerError represents InternalServerError.

func NewUnauthorizedError added in v1.0.0

func NewUnauthorizedError(err error) *StatusErr

NewUnauthorizedError represents UnauthorizedError.

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, if err's.

Jump to

Keyboard shortcuts

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