Handle internal server error using new custom template

This commit is contained in:
2024-05-14 11:35:15 +07:00
parent 420140918c
commit 43e16f1d79
17 changed files with 74 additions and 60 deletions

View File

@ -67,7 +67,7 @@ func GET(w http.ResponseWriter, r *http.Request) {
})
err := component.Render(r.Context(), w)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
log.Error(err.Error())
return
}
@ -82,7 +82,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
}
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
log.Error(err.Error())
return
}
@ -97,7 +97,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
})
err := component.Render(r.Context(), w)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
log.Error(err.Error())
return
}
@ -121,7 +121,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
})
err := component.Render(r.Context(), w)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
log.Error(err.Error())
return
}