iris: [BUG] View: If errors are returned by the ViewRenderer - do not output a "half template"

Describe the bug I am currently using the latest version from the Master Branch. If I use a template with Jet that uses variables that are not present, an error is returned, but the template is already sent to the browser as far as it has come, this should be prevented.

To Reproduce We have tried with and without iris.WithResetOnFireErrorCode but without ctx.Record()

app.Get("/bug-test", func(ctx iris.Context) {
	ctx.ViewData("demo", "123")
	if err := ctx.View("bugtest.jet"); err != nil {
		ctx.StopWithText(iris.StatusInternalServerError, "Templates not rendered!")
	}
})

Expected behavior Only the StopWithText should returned or the OnAnyErrorCode should be triggered. Not the half rendered Template.

I would expect, if a ViewEngine throws an error, that there will be no normal output, even if the template system has already sent it to the output.

An alternative would be to document it more clearly, in connection with the ViewEngines.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I thank you @Dexus, will take a look at the assesment for the certification of yours when I finish the documentation, I didnt forget it. I am freezing new features for v12.2.0.

It works now. Thanks @kataras

Just copy paste the most of it 😅 to not remove something that may have an impact.

Von meinem iPhone gesendet

Am 26.07.2020 um 18:17 schrieb Gerasimos (Makis) Maropoulos notifications@github.com:

Oh is this the simplest example you could give me? 😛 I see many things like translation and view functions, I will take a look of it, and get back to you soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.