2023-05-20 20:15:57 +02:00
|
|
|
// Copyright 2023 wanderer <a_mirre at utb dot cz>
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-04-21 12:33:14 +02:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2023-05-30 23:50:37 +02:00
|
|
|
"errors"
|
2023-04-21 12:33:14 +02:00
|
|
|
"fmt"
|
|
|
|
"strconv"
|
2023-05-06 21:50:35 +02:00
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
2023-04-21 12:33:14 +02:00
|
|
|
)
|
|
|
|
|
2023-05-30 23:50:37 +02:00
|
|
|
var (
|
|
|
|
ErrNoSession = errors.New("No session found, please log in")
|
|
|
|
ErrSessionExpired = errors.New("Session expired, log in again")
|
|
|
|
)
|
|
|
|
|
2023-05-06 21:50:35 +02:00
|
|
|
func renderErrorPage(c echo.Context, status int, statusText, error string) error {
|
2023-05-11 23:50:40 +02:00
|
|
|
addHeaders(c)
|
|
|
|
|
2023-04-21 12:33:14 +02:00
|
|
|
strStatus := strconv.Itoa(status)
|
|
|
|
|
2023-05-06 21:50:35 +02:00
|
|
|
return c.Render(
|
|
|
|
status,
|
|
|
|
"errorPage.tmpl",
|
2023-04-21 12:33:14 +02:00
|
|
|
page{
|
2023-05-03 02:18:29 +02:00
|
|
|
AppName: setting.AppName(),
|
2023-04-21 12:33:14 +02:00
|
|
|
AppVer: appver,
|
|
|
|
Title: fmt.Sprintf("Error %s - %s", strStatus, statusText),
|
2023-05-03 02:18:29 +02:00
|
|
|
DevelMode: setting.IsDevel(),
|
2023-04-21 12:33:14 +02:00
|
|
|
Current: strStatus,
|
|
|
|
Error: error,
|
|
|
|
Status: strStatus,
|
|
|
|
StatusText: statusText,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|