ecode

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodeOK 成功
	CodeOK = 0
	// CodeUnknown 未知错误
	CodeUnknown = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error records an error contains code and message and detailed error that caused it

func FromError

func FromError(err error) (*Error, bool)

FromError get Error from any error

func NewError

func NewError(code int, msg string) *Error

NewError return a new Error

func NewErrorWithDetail

func NewErrorWithDetail(code int, msg string, detail error) *Error

NewErrorWithDetail return a new Error with detailed error that caused it

func NewErrorf

func NewErrorf(code int, format string, args ...interface{}) *Error

NewErrorf return a new Error with a formatted message

func (*Error) Code

func (e *Error) Code() int

Code return error code

func (*Error) Detail

func (e *Error) Detail() error

Detail return detailed error

func (*Error) Error

func (e *Error) Error() string

Error implement error interface{}

func (*Error) Msg

func (e *Error) Msg() string

Msg return error msg

Jump to

Keyboard shortcuts

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