ecode

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK    = 0
	StatusError = 1
)

Variables

This section is empty.

Functions

func StatusText added in v0.0.5

func StatusText(code int) string

Types

type ErrorCode

type ErrorCode interface {
	// sometimes Error return Code in string form
	// NOTE: don't use Error in monitor report even it also work for now
	Error() string
	// Code get error code.
	Code() int
	// Message get code message.
	Message() string
	//Detail get error detail,it may be nil.
	Details() []interface{}
}

Codes ecode error interface which has a code & message.

func New added in v0.0.6

func New(err error) ErrorCode

type Status

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

func Error

func Error(code int, message string, objects ...interface{}) *Status

Error new status with code and message

func Errorf

func Errorf(code int, format string, args ...interface{}) *Status

Errorf new status with code and message

func (*Status) Code

func (s *Status) Code() int

Code return error code

func (*Status) Details

func (s *Status) Details() []interface{}

Details return error details

func (*Status) Error

func (s *Status) Error() string

Error implement error

func (*Status) Message

func (s *Status) Message() string

Message return error message for developer

func (*Status) WithDetails

func (s *Status) WithDetails(objects ...interface{}) *Status

WithDetails WithDetails

Jump to

Keyboard shortcuts

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