暂存
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m32s

This commit is contained in:
2026-08-06 09:35:00 +08:00
parent 8659dfc658
commit 88cc5e96ec
75 changed files with 6520 additions and 513 deletions

View File

@@ -28,6 +28,7 @@ type AppError struct {
Code int // 应用错误码
Message string // 错误消息
Err error // 底层错误(可选)
Data any // 可安全返回的结构化错误上下文(可选)
}
func (e *AppError) Error() string {
@@ -59,6 +60,13 @@ func New(code int, customMsg ...string) *AppError {
}
}
// NewWithData 创建携带安全结构化上下文的 AppError。
func NewWithData(code int, data any, customMsg ...string) *AppError {
err := New(code, customMsg...)
err.Data = data
return err
}
// Wrap 用错误码和消息包装现有错误
// 优先使用 errorMessages 映射表中的消息,允许通过可选参数覆盖
// 用法: