/* * Copyright (C) 2023 Jonni Liljamo * * This file is licensed under AGPL-3.0-or-later, see NOTICE and LICENSE for * more information. */ package util import ( "net/http" "tixe/template" "github.com/gin-gonic/gin" ) func RenderError(c *gin.Context, title string, errStr string, user interface{}) { var html []byte if user == nil { html = template.TmplEngine.Render("error.tmpl", map[string]interface{}{"title": title, "error": errStr, "notauthed": true}) } else { html = template.TmplEngine.Render("error.tmpl", map[string]interface{}{"title": title, "error": errStr, "user": user}) } c.Data(http.StatusInternalServerError, "text/html", html) c.Abort() }