package apierrors import ( "encoding/json" "errors" "io" ) // ExportCatalog writes normalized, public-only error metadata. Invoke this // explicitly from project tooling, using the same Catalog function registered // at runtime. The API CLI reads the artifact; it never executes project code. func ExportCatalog(w io.Writer, c Catalog) error { if w == nil { return errors.New("errors: catalog export writer required") } registry, err := NewRegistry(c) if err != nil { return err } encoder := json.NewEncoder(w) encoder.SetIndent("", " ") return encoder.Encode(registry.Catalog()) }