feat: add typed error message templates and stable replay snapshots

This commit is contained in:
2026-09-24 15:05:08 +08:00
parent 2041e7f661
commit 6e3f025aad
32 changed files with 1570 additions and 99 deletions

View File

@@ -0,0 +1,48 @@
syntax = "v1"
errorCatalog CommonErrors (
defaultStatus: 200
errors: {
"TextTooLong": {
"key": "TEXT_TOO_LONG",
"code": 400002,
"message": "{label}不能超过{max}个字符",
"params": [
{"name": "label", "type": "string", "example": "企业名称"},
{"name": "max", "type": "int", "example": 100}
]
},
"UsernameInvalid": {"key": "USERNAME_INVALID", "code": 400003, "message": "用户名格式不正确"},
"ResourceDenied": {
"key": "RESOURCE_DENIED", "status": 403, "code": 403001,
"message": "{label}不可用",
"params": [{"name": "label", "type": "string", "example": "资源"}]
}
}
)
response CommonResponse (
codeType: int32
successCode: 0
errorCode: 9999
body: {"code": "${code}", "msg": "${message}", "data": "${data}"}
dataMode: always
)
type TokenResponse {
Token string `json:"token"`
}
@server (
group: account
response: CommonResponse
errors: TextTooLong, UsernameInvalid, ResourceDenied
)
service error-params-api {
@handler token
post /token returns (TokenResponse)
@response raw
@handler raw
get /raw returns (TokenResponse)
}