refactor(core): 任务与模型协议治理 - 拆分服务职责并禁止已发起任务取消
This commit is contained in:
1 parent
7418ddfa9c
commit
633560a5d8
91 files changed
+6380
-4247
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package service
|
||||
|
||||
// AppError 是 service 层对外公开的结构化错误。
|
||||
// Message 必须可安全展示给用户,Cause 仅用于保留内部诊断链路,不得直接写入 HTTP 响应。
|
||||
type AppError struct {
|
||||
Status int
|
||||
Code int
|
||||
Message string
|
||||
Retryable bool
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (e *AppError) Error() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (e *AppError) Unwrap() error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return e.Cause
|
||||
}
|
||||
|
||||
func NewAppError(status int, message string) *AppError {
|
||||
return &AppError{Status: status, Message: message}
|
||||
}
|
||||
|
||||
func WrapAppError(status int, message string, cause error) *AppError {
|
||||
return &AppError{Status: status, Message: message, Cause: cause}
|
||||
}
|
||||
Reference in new issue
Block a user