DEVELOPMENT ENVIRONMENT

~liljamo/tixe

ref: acbe0c9841bcbe6cadc3300fef092ce551e76421 tixe/util/error.go -rw-r--r-- 697 bytes
acbe0c98Jonni Liljamo feat: error.tmpl 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * 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()
}