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

@@ -60,6 +60,9 @@ func MustWithErrors(catalog apierrors.Catalog, next Encoder) Encoder {
}
func (f *Formatter) ValidateErrors(catalog apierrors.Catalog) error {
for key, d := range catalog.Definitions {
if _, ok := f.config.Messages[key]; ok && len(d.Params) > 0 {
return fmt.Errorf("response: templated error %s must define its message only in the catalog", key)
}
if err := f.validateError(Result{Code: key, Message: d.Message, BusinessCode: d.Code, Failed: true}); err != nil {
return err
}