feat: import services and standardize Go 1.26.5
This commit is contained in:
34
apps/ec/delivery/internal/errorcode/errorcode.go
Normal file
34
apps/ec/delivery/internal/errorcode/errorcode.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package errorcode
|
||||
|
||||
import "fmt"
|
||||
|
||||
type CError struct {
|
||||
ErrorCode string
|
||||
Msg string
|
||||
Title string
|
||||
}
|
||||
|
||||
var (
|
||||
ErrTokenAuth = CError{ErrorCode: "3801", Msg: "Token Not Found", Title: "无效token"}
|
||||
ErrInvalidArgument = CError{ErrorCode: "3801", Msg: "Invalid Argument", Title: "无效参数"}
|
||||
ErrorJson = CError{ErrorCode: "3802", Msg: "Json Format Error", Title: "json格式错误"}
|
||||
ErrIdentityArgument = CError{ErrorCode: "3803", Msg: "Invalid parameter:identity", Title: "identity参数无效"}
|
||||
ErrPasswordArgument = CError{ErrorCode: "3804", Msg: " Invalid parameter:password", Title: "password参数无效"}
|
||||
ErrAuthPasswd = CError{ErrorCode: "3805", Msg: " Auth Password", Title: "password验证失败"}
|
||||
ErrDBFatal = CError{ErrorCode: "3806", Msg: "DB Fatal", Title: "数据错误"}
|
||||
ErrBalance = CError{ErrorCode: "3807", Msg: "Err Balance", Title: "余额异常"}
|
||||
ErrNotFound = CError{ErrorCode: "3809", Msg: "Err Not Found", Title: "数据未找到"}
|
||||
ErrPermissionDenied = CError{ErrorCode: "3810", Msg: "No Access", Title: "无权访问"}
|
||||
)
|
||||
|
||||
func (e *CError) Error() string {
|
||||
return fmt.Sprintf("Error Code: %s, Message: %s", e.ErrorCode, e.Msg)
|
||||
}
|
||||
|
||||
// 函数返回自定义错误
|
||||
func ContentError(err CError) error {
|
||||
return &CError{
|
||||
ErrorCode: err.ErrorCode,
|
||||
Msg: err.Msg,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user