summaryrefslogtreecommitdiffstats
path: root/web/handler/index.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/handler/index.go')
-rw-r--r--web/handler/index.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/web/handler/index.go b/web/handler/index.go
index 9279151..8b3d43c 100644
--- a/web/handler/index.go
+++ b/web/handler/index.go
@@ -2,7 +2,7 @@ package handler
import (
"html/template"
- "log"
+ "log/slog"
"net/http"
"git.leonardobishop.net/instancer/pkg/registry"
@@ -13,14 +13,20 @@ func GetIndex(tmpl *template.Template, registryClient *registry.RegistryClient)
return func(w http.ResponseWriter, r *http.Request) {
challenges, err := registryClient.ListRepositories()
if err != nil {
- log.Printf("Could not list repositories: %v", err)
- http.Error(w, "Internal server error", http.StatusInternalServerError)
+ slog.Error("could not list repositories", "cause", err)
+ tmpl.ExecuteTemplate(w, "problem.html", struct {
+ Error string
+ ShowLogout bool
+ }{
+ Error: "Error occured fetching available challenges. Please try again.",
+ ShowLogout: false,
+ })
return
}
session := r.Context().Value("session").(*session.UserSession)
- if err := tmpl.ExecuteTemplate(w, "index.html", struct {
+ tmpl.ExecuteTemplate(w, "index.html", struct {
Challenges []string
Name string
Team string
@@ -28,9 +34,6 @@ func GetIndex(tmpl *template.Template, registryClient *registry.RegistryClient)
Challenges: challenges,
Name: session.Name,
Team: session.TeamName,
- }); err != nil {
- http.Error(w, "Internal server error", http.StatusInternalServerError)
- return
- }
+ })
}
}