pages-server/html/error.go

28 lines
577 B
Go
Raw Normal View History

2021-12-05 13:47:33 +00:00
package html
import (
2022-07-15 16:10:41 +00:00
"net/http"
2021-12-05 13:47:33 +00:00
"strconv"
2022-08-28 14:21:37 +00:00
"strings"
2021-12-05 13:47:33 +00:00
)
2022-07-15 16:10:41 +00:00
func errorMessage(statusCode int) string {
message := http.StatusText(statusCode)
switch statusCode {
case http.StatusMisdirectedRequest:
2021-12-05 13:47:33 +00:00
message += " - domain not specified in <code>.domains</code> file"
2022-07-15 16:10:41 +00:00
case http.StatusFailedDependency:
2021-12-05 13:47:33 +00:00
message += " - target repo/branch doesn't exist or is private"
}
2022-07-15 16:10:41 +00:00
return message
}
// TODO: use template engine?
2022-08-28 14:21:37 +00:00
func errorBody(statusCode int) string {
return strings.ReplaceAll(NotFoundPage,
"%status",
strconv.Itoa(statusCode)+" "+errorMessage(statusCode))
2021-12-05 13:47:33 +00:00
}