feat(types,model): 实现阶段 1 基础设施 — 错误码、AppError、配置模型、核心接口

This commit is contained in:
hhs
2026-06-10 12:49:29 +08:00
parent 1cfebd37be
commit 53488f792d
4 changed files with 270 additions and 0 deletions

View File

@@ -1 +1,12 @@
package types
const (
CodeSuccess = "0000"
InfoSuccess = "success"
CodeUnknownError = "0001"
InfoUnknownError = "unknown error"
CodeIllegalParameter = "0002"
InfoIllegalParameter = "illegal parameter"
CodeAgentNotFound = "0003"
InfoAgentNotFound = "agent not found"
)

View File

@@ -1 +1,17 @@
package types
type AppError struct {
Code string
Info string
}
func NewAppError(code, info string) *AppError {
return &AppError{Code: code, Info: info}
}
func (e *AppError) Error() string {
if e == nil {
return ""
}
return e.Code + ": " + e.Info
}