Verbessere Logging und Fehlerbehandlung

This commit is contained in:
Gonne 2022-09-21 22:24:08 +02:00
parent c737818ce4
commit 6e97d867de
14 changed files with 223 additions and 88 deletions

View file

@ -1,6 +1,7 @@
package controllers
import (
"log"
"net/http"
)
@ -10,16 +11,24 @@ func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Req
if err != nil {
w.WriteHeader(http.StatusNotFound)
Templates.ExecuteTemplate(w, "requestNotFound.html", struct{}{})
templateError := Templates.ExecuteTemplate(w, "requestNotFound.html", struct{}{})
if templateError != nil {
log.Printf("Error executing template requestNotFound.html: %s", templateError.Error())
}
return
}
err = b.requestRepo.Execute(request)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Templates.ExecuteTemplate(w, "executeFailure.html", err.Error())
templateError := Templates.ExecuteTemplate(w, "executeFailure.html", err.Error())
if templateError != nil {
log.Printf("Error executing template executeFailure.html: %s", templateError.Error())
}
return
}
Templates.ExecuteTemplate(w, "executeSuccess.html", struct{}{})
templateError := Templates.ExecuteTemplate(w, "executeSuccess.html", struct{}{})
if templateError != nil {
log.Printf("Error executing template executeSuccess.html: %s", templateError.Error())
}
}