This commit is contained in:
2024-10-12 20:41:55 +08:00
parent 8c09120db6
commit 597e4f1b89
75 changed files with 5009 additions and 823 deletions

20
pkg/errs/err.go Normal file
View File

@@ -0,0 +1,20 @@
package errs
// 定义自定义错误类型
type AppError struct {
Code int // 错误码
Message string // 错误信息
}
// 实现 error 接口的 Error 方法
func (e *AppError) Error() string {
return e.Message
}
// 创建带有错误码和错误信息的 AppError
func NewAppError(code int, message string) *AppError {
return &AppError{
Code: code,
Message: message,
}
}