errs

package
v0.0.0-...-a9a82f6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InternalError  = NewError("internal error")
	BadRequest     = NewError("bad request", http.StatusBadRequest)
	UserBlocked    = NewError("user is blocked", http.StatusUnauthorized)
	SessionInvalid = NewError("session invalid", http.StatusUnauthorized)
)

Functions

func HttpError

func HttpError(w http.ResponseWriter, err error)

Types

type Err

type Err struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
	Err     error  `json:"err"`
}

func NewError

func NewError(message string, code ...int) *Err

func (*Err) AddMessage

func (e *Err) AddMessage(message string) *Err

func (Err) Error

func (e Err) Error() string

func (*Err) GetCode

func (e *Err) GetCode() int

func (*Err) GetMessage

func (e *Err) GetMessage() string

func (*Err) HTTP

func (e *Err) HTTP(code int) *Err

func (Err) Unwrap

func (e Err) Unwrap() error

Jump to

Keyboard shortcuts

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