package handlers import ( "net/http" "git.haelnorr.com/h/golib/hws" "git.haelnorr.com/h/oslstats/internal/view/page" "github.com/pkg/errors" ) func ErrorPage( errorCode int, ) (hws.ErrorPage, error) { messages := map[int]string{ 400: "The request you made was malformed or unexpected.", 401: "You need to login to view this page.", 403: "You do not have permission to view this page.", 404: "The page or resource you have requested does not exist.", 500: `An error occured on the server. Please try again, and if this continues to happen contact an administrator.`, 503: "The server is currently down for maintenance and should be back soon. =)", } msg, exists := messages[errorCode] if !exists { return nil, errors.New("No valid message for the given code") } return page.Error(errorCode, http.StatusText(errorCode), msg), nil }