v0.0.619 better handle error in ginext.JSON() with invalid data
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m26s

This commit is contained in:
2026-01-08 22:58:50 +01:00
parent 0f28e3d11b
commit 580906ea08
5 changed files with 60 additions and 15 deletions

View File

@@ -2,9 +2,11 @@ package ginext
import (
"fmt"
"net/http"
"strings"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"github.com/gin-gonic/gin"
"net/http"
)
type WHandlerFunc func(PreContext) HTTPResponse
@@ -54,8 +56,16 @@ func Wrap(w *GinWrapper, fn WHandlerFunc) gin.HandlerFunc {
lstr(g, wrap)
}
if g.IsAborted() {
return
}
if reqctx.Err() == nil {
wrap.Write(g)
if g.IsAborted() {
// can happen if we try to marshal an invalid json object (e.g. containing Inf)
panic("Failed to write response to renderer:\n" + strings.Join(g.Errors.Errors(), "\n"))
}
}
}
}