print errlog (jsonv2 marshal)

This commit is contained in:
WJQSERVER 2026-01-26 08:08:01 +08:00
parent 7b536ac137
commit a6e278d458
3 changed files with 7 additions and 16 deletions

View file

@ -410,6 +410,7 @@ func (c *Context) JSON(code int, obj any) {
c.Writer.WriteHeader(code)
if err := json.MarshalWrite(c.Writer, obj); err != nil {
c.AddError(fmt.Errorf("failed to marshal JSON: %w", err))
c.Errorf("failed to marshal JSON: %s", err)
c.ErrorUseHandle(http.StatusInternalServerError, fmt.Errorf("failed to marshal JSON: %w", err))
return
}