t_error

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-3-Clause Imports: 2 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	INTERNAL_ERROR_MSG         = "Internal error."
	INTERNAL_ERROR_CODE uint64 = 1
	NETWORK_ERROR_MSG          = "Network error."
	NETWORK_ERROR_CODE  uint64 = 2

	INTERNAL_ERROR = WrapWithCode(fmt.Errorf(INTERNAL_ERROR_MSG), INTERNAL_ERROR_CODE)
	NETWORK_ERROR  = WrapWithCode(fmt.Errorf(NETWORK_ERROR_MSG), NETWORK_ERROR_CODE)
)

Functions

func Recover added in v0.0.11

func Recover(fun func(*ErrorInfo))

func ThrowInternal added in v0.0.11

func ThrowInternal(err error)

func ThrowWithCode added in v0.0.11

func ThrowWithCode(err error, code uint64)

func ThrowWithCodeAndData added in v0.0.11

func ThrowWithCodeAndData(err error, code uint64, data error)

func WithStack added in v0.0.11

func WithStack(err error) error

Types

type ErrorInfo

type ErrorInfo struct {
	Code uint64      `json:"code"`
	Data interface{} `json:"data"`
	Err  error       `json:"err"`
}

func Wrap added in v0.0.11

func Wrap(err error) *ErrorInfo

func WrapWithAll added in v0.0.11

func WrapWithAll(err error, code uint64, data interface{}) *ErrorInfo

func WrapWithCode added in v0.0.11

func WrapWithCode(err error, code uint64) *ErrorInfo

func WrapWithErr added in v0.0.11

func WrapWithErr(err error) *ErrorInfo

func WrapWithStr added in v0.0.11

func WrapWithStr(str string) *ErrorInfo

func (*ErrorInfo) Error added in v0.0.10

func (ei *ErrorInfo) Error() string

func (*ErrorInfo) String added in v0.0.10

func (ei *ErrorInfo) String() string

func (*ErrorInfo) Unwrap added in v0.0.10

func (ei *ErrorInfo) Unwrap() error

Jump to

Keyboard shortcuts

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