Files
Error-Code-System/domains/register.go
T
weichenandCursor bd53e9ba79
ci / vet-and-test (push) Successful in 3s
ci / docker-checkout-hostgateway (push) Successful in 3s
Add a shared error-code catalog so failures can be traced by stable codes.
Services can resolve legacy aliases and expose the catalog over CLI and HTTP instead of ad-hoc error strings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 13:43:12 +00:00

34 lines
1004 B
Go

// Package domains 把种子错误码登记进注册表。
//
// Go 定义是权威来源。同目录 JSON 由导出生成,经 go:embed 提供给不编译 Go 的消费方;
// conformance 测试保证二者一致。导入本包会填充 errcode.Default。
package domains
import "error-code-system/errcode"
func init() { RegisterAll(errcode.Default) }
// RegisterAll 向 r 登记 sys / agent / squad 三域。重复调用会因码冲突失败。
func RegisterAll(r *errcode.Registry) {
registerSys(r)
registerAgent(r)
registerSquad(r)
}
func must(r *errcode.Registry, def errcode.Definition) {
r.MustRegister(def)
}
func def(code errcode.Code, http int, sev errcode.Severity, retry errcode.Retry, side errcode.SideEffects, summary, hint string, aliases ...string) errcode.Definition {
return errcode.Definition{
Code: code,
HTTP: http,
Severity: sev,
Retry: retry,
SideEffects: side,
Summary: summary,
Hint: hint,
Aliases: aliases,
}
}