Rendering error throws a panic()
This commit is contained in:
parent
9abb909731
commit
2fc2a3e782
@ -369,15 +369,10 @@ func (c *Context) GetCookie(name string) (string, error) {
|
|||||||
func (c *Context) Render(code int, r render.Render) {
|
func (c *Context) Render(code int, r render.Render) {
|
||||||
c.Status(code)
|
c.Status(code)
|
||||||
if err := r.Render(c.Writer); err != nil {
|
if err := r.Render(c.Writer); err != nil {
|
||||||
c.renderError(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) renderError(err error) {
|
|
||||||
debugPrintError(err)
|
|
||||||
c.AbortWithError(500, err).SetType(ErrorTypeRender)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTML renders the HTTP template specified by its file name.
|
// HTML renders the HTTP template specified by its file name.
|
||||||
// It also updates the HTTP code and sets the Content-Type as "text/html".
|
// It also updates the HTTP code and sets the Content-Type as "text/html".
|
||||||
// See http://golang.org/doc/articles/wiki/
|
// See http://golang.org/doc/articles/wiki/
|
||||||
@ -399,7 +394,7 @@ func (c *Context) IndentedJSON(code int, obj interface{}) {
|
|||||||
func (c *Context) JSON(code int, obj interface{}) {
|
func (c *Context) JSON(code int, obj interface{}) {
|
||||||
c.Status(code)
|
c.Status(code)
|
||||||
if err := render.WriteJSON(c.Writer, obj); err != nil {
|
if err := render.WriteJSON(c.Writer, obj); err != nil {
|
||||||
c.renderError(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user