mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-10 20:53:50 +08:00
20 lines
607 B
Go
20 lines
607 B
Go
package server
|
|
|
|
import "net/http"
|
|
|
|
// productMessage keeps the original detail alongside a stable translation key.
|
|
type productMessage struct {
|
|
Code string `json:"code"`
|
|
Params map[string]any `json:"params,omitempty"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// Preserve error for existing clients and add stable fields for localized UIs.
|
|
func writeProductError(w http.ResponseWriter, status int, code, message string, params map[string]any) {
|
|
payload := map[string]any{"error": message, "code": code}
|
|
if len(params) > 0 {
|
|
payload["params"] = params
|
|
}
|
|
writeJSON(w, status, payload)
|
|
}
|