simplerr

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 5 Imported by: 3

README

simplerr

Documentation

Overview

Package simplerr implement error with code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetText added in v0.2.0

func GetText(err error) string

func GetWithCode added in v0.6.0

func GetWithCode(err error) error

func HasCode

func HasCode(err error, code ErrCode) bool

func Is

func Is(err, target error) bool

func New added in v0.9.0

func New(msg string) error

func NewWithCode added in v0.9.0

func NewWithCode(msg string, code ErrCode) error

func WithCode added in v0.4.0

func WithCode(err error, code ErrCode) error

func WithStack added in v0.7.0

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, msg string) error

func WrapWithCode

func WrapWithCode(err error, code ErrCode, msg string) error

func Wrapf

func Wrapf(err error, tmpl string, args ...interface{}) error

func WrapfWithCode

func WrapfWithCode(err error, code ErrCode, tmpl string, args ...interface{}) error

Types

type Call

type Call struct {
	Line     int
	File     string
	FuncName string
}

func GetStack

func GetStack(err error) []Call

type ErrCode added in v0.5.0

type ErrCode interface {
	HTTP() int
	GRPC() int
	Int() int
}

func AlreadyExistsCode added in v0.8.0

func AlreadyExistsCode(c int) ErrCode

func ForbiddenCode added in v0.8.0

func ForbiddenCode(c int) ErrCode

func GetCode

func GetCode(err error) ErrCode

func InternalCode added in v0.8.0

func InternalCode(c int) ErrCode

func InvalidArgumentCode added in v0.8.1

func InvalidArgumentCode(c int) ErrCode

func NotFoundCode added in v0.8.0

func NotFoundCode(c int) ErrCode

func UnauthorizedCode added in v0.8.0

func UnauthorizedCode(c int) ErrCode

Jump to

Keyboard shortcuts

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