errors

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// system
	InternalError = NewError("internal error").HTTP(http.StatusInternalServerError)

	// network errors
	NetworkBadURL      = NewError("bad url")
	NetworkBadRequest  = NewError("bad http request")
	NetworkBadResponse = NewError("bad http response")

	BadName = NewError("bad name").HTTP(http.StatusBadRequest)
	BadId   = NewError("bad id").HTTP(http.StatusBadRequest)

	// game
	GameExist          = NewError("game exist").HTTP(http.StatusBadRequest)
	GameNotExists      = NewError("game not exists").HTTP(http.StatusNoContent)
	GameInfoNotExists  = NewError("game info not exists")
	GameImageNotExists = NewError("game image not exists").HTTP(http.StatusNoContent)

	// collection
	CollectionExist          = NewError("collection exist").HTTP(http.StatusBadRequest)
	CollectionNotExists      = NewError("collection not exists").HTTP(http.StatusNoContent)
	CollectionInfoNotExists  = NewError("collection info not exists")
	CollectionImageNotExists = NewError("collection image not exists").HTTP(http.StatusNoContent)

	// deck
	DeckExist          = NewError("deck exist").HTTP(http.StatusBadRequest)
	DeckNotExists      = NewError("deck not exists").HTTP(http.StatusNoContent)
	DeckImageNotExists = NewError("deck image not exists").HTTP(http.StatusNoContent)

	// card
	CardExists         = NewError("card exists").HTTP(http.StatusInternalServerError)
	CardNotExists      = NewError("card not exists").HTTP(http.StatusNoContent)
	CardImageNotExists = NewError("card image not exists").HTTP(http.StatusNoContent)

	// image
	UnknownImageType = NewError("unknown image type").HTTP(http.StatusBadRequest)

	// zip
	BadArchive = NewError("bad zip archive").HTTP(http.StatusBadRequest)
)

Functions

func IfErrorLog

func IfErrorLog(err error)

Types

type Err

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

func NewError

func NewError(message string) *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