From 096349bb56d88d0714f499f513a6a0e1356e744e Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Thu, 10 Mar 2022 20:41:34 +0200 Subject: [PATCH] view: minor --- context/context.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/context/context.go b/context/context.go index 40072716..ea3e99bd 100644 --- a/context/context.go +++ b/context/context.go @@ -33,7 +33,6 @@ import ( "github.com/fatih/structs" gojson "github.com/goccy/go-json" "github.com/iris-contrib/schema" - "github.com/kataras/golog" "github.com/mailru/easyjson" "github.com/mailru/easyjson/jwriter" "github.com/microcosm-cc/bluemonday" @@ -3627,15 +3626,18 @@ func (ctx *Context) View(filename string, optionalViewModel ...interface{}) erro ctx.ContentType(ContentHTMLHeaderValue) err := ctx.renderView(filename, optionalViewModel...) - if errNotExists, ok := err.(ErrViewNotExist); ok { - err = ctx.fireFallbackViewOnce(errNotExists) + if err != nil { + if errNotExists, ok := err.(ErrViewNotExist); ok { + err = ctx.fireFallbackViewOnce(errNotExists) + } } if err != nil { - if ctx.app.Logger().Level == golog.DebugLevel { + if ctx.IsDebug() { // send the error back to the client, when debug mode. ctx.StopWithError(http.StatusInternalServerError, err) } else { + ctx.SetErrPrivate(err) ctx.StopWithStatus(http.StatusInternalServerError) } }