refactor(error): 重构错误处理机制,使用ErrorCode枚举替代OutInfo接口
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
package errorcode
|
||||
|
||||
import "github.com/tnnmigga/enum"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
// ErrorCode 错误码枚举类型
|
||||
type ErrorCode uint32
|
||||
|
||||
func (t ErrorCode) Code() string { return fmt.Sprintf("%d", t) }
|
||||
|
||||
// ErrorMap 错误码到错误信息的映射
|
||||
//var ErrorMap = make(map[ErrorCode]ErrorInfo)
|
||||
|
||||
// ErrorCodes 错误码注册表
|
||||
var ErrorCodes = enum.New[struct {
|
||||
// 系统错误码
|
||||
ErrLoginFailed ErrorCode `enum:"10001"` // 登录失败
|
||||
// 登录失败
|
||||
ErrLoginFailed ErrorCode `enum:"10001"`
|
||||
ErrAlreadyLoggedIn ErrorCode `enum:"10004"` // 已在别处登录
|
||||
ErrIllegalLanguage ErrorCode `enum:"10005"` // 使用非法语言
|
||||
ErrUserOffline ErrorCode `enum:"10006"` // 用户离线
|
||||
|
||||
Reference in New Issue
Block a user