errs

package
v0.0.0-...-c4aec86 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDB = TodoError{DBErr, "internal error", 500}

ErrDB is a canned error for unexpected DB Errors

View Source
var ErrInternal = TodoError{InternalErr, "internal error", 500}

ErrInternal is a canned error for unexpected service Errors

View Source
var ErrInvalidRequest = TodoError{InputError, "invalid request", 400}

ErrInvalidRequest is a canned error for invalid user ID

View Source
var ErrInvalidUser = TodoError{InvalidUserErr, "invalid user", 404}

ErrInvalidUser is a canned error for invalid user ID

View Source
var ErrNotFound = TodoError{NotFoundErr, "not found", 404}

ErrNotFound is a canned error for not found (http 404)

View Source
var ErrUnauthorized = TodoError{AuthErr, "invalid authorization", 401}

ErrUnauthorized is a canned error for lack of authorization (http 401)

Functions

func IsNotFound

func IsNotFound(err error) bool

func IsNotNoRows

func IsNotNoRows(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func New

func New(c ErrorCode, msg string, h int) error

Types

type ErrorCode

type ErrorCode byte
const (
	// UndefinedErr is used to signify an unknown/uninitialized status
	UndefinedErr ErrorCode = iota
	AuthErr
	ConfigErr
	DBErr
	InvalidUserErr
	NotFoundErr
	InputError
	InternalErr
)

func (ErrorCode) Error

func (e ErrorCode) Error() string

type TodoError

type TodoError struct {
	ErrorCode ErrorCode `json:"code"`
	Message   string    `json:"message"`
	HttpCode  int       `json:"http_code"`
}

func (TodoError) Body

func (e TodoError) Body() string

func (TodoError) Code

func (e TodoError) Code() string

func (TodoError) Error

func (e TodoError) Error() string

func (TodoError) Public

func (e TodoError) Public() bool

Jump to

Keyboard shortcuts

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