statuserr

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrToStatus

func ErrToStatus(err error) int

ErrToStatus tries to extract status code from error. If the error is not ErrWithStatus returns status 500.

func ErrWrap

func ErrWrap(status int, err error, message string) error

ErrWrap wraps an error inside ErrWithStatus with additional message.

func ErrWrapf

func ErrWrapf(status int, err error, format string, args ...interface{}) error

ErrWrapf wraps an error inside ErrWithStatus with additional formatted message.

func NewErr

func NewErr(status int, err error) error

NewErr creates ErrWithStatus as error interface.

Types

type ErrWithStatus

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

ErrWithStatus represents error with status code. It can be hidden behind standard error interface and wrapped with errors.Wrap.

func (*ErrWithStatus) Error

func (e *ErrWithStatus) Error() string

Error returns error string.

Jump to

Keyboard shortcuts

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