You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In summary, ErrorTypeRender does not appear to be used anywhere in the code.
We discovered this issue when we were having marshalling failures in context.JSON(). We tried checking context.Errors for errors with type ErrorTypeRender, and realised that nowhere in the code is that set.
Could open a PR for this but wanted to confirm if it was intended or not, since ErrorTypes are super old. I could not find any thread or issue that would suggest it though.
How to reproduce
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/gin-gonic/gin"
)
type ProblemObj struct {
}
func (f *ProblemObj) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("this is an error")
}
func main() {
c, _ := gin.CreateTestContext(httptest.NewRecorder())
prob := &ProblemObj{}
c.JSON(http.StatusOK, prob)
for _, err := range c.Errors {
fmt.Println(err.IsType(gin.ErrorTypeRender))
}
}
Expectations
The test code should print true, since the error was occurred during rendering.
Actual result
The test code prints false.
Environment
go version: v1.21.1
gin version (or commit ref): v1.9.1 and v1.10.0
operating system: Mac AMD64
The text was updated successfully, but these errors were encountered:
I checked the relevant functions and submission history. This method is quite old and modifications may have a greater impact.
I feel that it is not suitable to modify it directly. It is more appropriate to write a branch function and handle it separately for Render.
Description
In summary, ErrorTypeRender does not appear to be used anywhere in the code.
We discovered this issue when we were having marshalling failures in
context.JSON()
. We tried checkingcontext.Errors
for errors with typeErrorTypeRender
, and realised that nowhere in the code is that set.Could open a PR for this but wanted to confirm if it was intended or not, since ErrorTypes are super old. I could not find any thread or issue that would suggest it though.
How to reproduce
Expectations
The test code should print true, since the error was occurred during rendering.
Actual result
The test code prints false.
Environment
The text was updated successfully, but these errors were encountered: