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
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m26s
This commit is contained in:
@@ -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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user