Rendering error throws a panic()

This commit is contained in:
Manu Mtz.-Almeida 2016-01-26 18:35:04 +01:00
parent 9abb909731
commit 2fc2a3e782
1 changed files with 2 additions and 7 deletions

View File

@ -369,15 +369,10 @@ func (c *Context) GetCookie(name string) (string, error) {
func (c *Context) Render(code int, r render.Render) {
c.Status(code)
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.
// It also updates the HTTP code and sets the Content-Type as "text/html".
// 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{}) {
c.Status(code)
if err := render.WriteJSON(c.Writer, obj); err != nil {
c.renderError(err)
panic(err)
}
}