errs

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS         = "Success"
	AUTH_ERROR      = 995 // 权限错误
	PARAMETER_ERROR = 996 // 参数错误
	SERVER_ERROR    = 997 // 系统错误
	NOT_FOUND       = 998 // 404错误
	UNKNOWN_ERROR   = 999 // 未知错误
)

Success 成功提示字符串

Variables

This section is empty.

Functions

func Code

func Code(e error) int

Code 通过error获取error code

func Msg

func Msg(e error) string

Msg 通过error获取error msg

func SetTraceable

func SetTraceable(x bool)

SetTraceable 控制error是否带堆栈跟踪

Types

type Error

type Error struct {
	Code int
	Msg  string
	Desc string
	// contains filtered or unexported fields
}

Error 错误码结构 包含 错误码类型 错误码 错误信息

func New

func New(code int, msg string) *Error

New 创建一个error,默认为业务错误类型,提高业务开发效率

func Newf

func Newf(code int, format string, params ...interface{}) *Error

Newf 创建一个error,默认为业务错误类型,msg支持格式化字符串

func (*Error) Error

func (e *Error) Error() string

Error 实现error接口,返回error描述

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL