exception

package
v0.3.58 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_COMMON_BUSY         = ERR_COMMON + (iota + 1) // 服务器繁忙
	ERR_COMMON_REQ_TOOMANEY                           // 请求过多
	ERR_COMMON_BADPARAM                               // 参数错误
	ERR_COMMON_UNAUTH                                 // 登录失效
	ERR_COMMON_NOPERMISSION                           // 没有权限
	ERR_COMMON_USER                                   // 操作人错误
	ERR_COMMON_TIMEOUT                                // 超时
)

通用错误码

View Source
const (
	ERR_VERIFYCODE_SENDFAIL   = ERR_VERIFYCODE + (iota + 1) // 发送验证码失败
	ERR_VERIFYCODE_HASSEND                                  // 验证码已经发送过
	ERR_VERIFYCODE_HASEXPIRED                               // 验证码已经过期
)

验证码错误

View Source
const (
	ERR_BUSI_NOFOUND  = ERR_BUSI + (iota + 1) // 没有找到
	ERR_BUSI_HASEXIST                         // 已经存在
	ERR_BUSI_CREATE                           // 创建失败
	ERR_BUSI_UPDATE                           // 更新失败
	ERR_BUSI_DELETE                           // 删除失败
	ERR_BUSI_STATUS                           // 状态错误
)

业务错误

Variables

This section is empty.

Functions

This section is empty.

Types

type Exception

type Exception interface {
	Code() int32
	error
}

func New

func New(ex ExceptionType, s string) Exception

New函数用于创建一个Exception对象,该对象包含一个异常类型ex和一个字符串s。

func Wrap

func Wrap(ex ExceptionType, err error, msgs ...string) Exception

Wrap函数用于创建一个Exception类型的对象,该对象包含了一个异常类型ex、一个错误err和一个可变参数msgs。 当msgs参数为空时,返回一个errorString对象,该对象的ex字段为ex,err字段为err。 当msgs参数只有一个元素时,返回一个errorString对象,该对象的ex字段为ex,err字段为err,s字段为msgs[0]。 当msgs参数有多个元素时,返回一个errorString对象,该对象的ex字段为ex,err字段为err,s字段为msgs所有元素用逗号连接起来的字符串。

type ExceptionType

type ExceptionType int32
const (
	ERR_COMMON     ExceptionType = (iota + 1) * 10000 // 通用错误码
	ERR_VERIFYCODE                                    // 验证码错误
	ERR_BUSI                                          // 通用业务操作错误
	ERR_UNRESPONSE                                    // 没有响应
)

通用错误大类

func (ExceptionType) New

func (ex ExceptionType) New(s string) Exception

func (ExceptionType) Wrap

func (ex ExceptionType) Wrap(err error, msgs ...string) Exception

Jump to

Keyboard shortcuts

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