use servemux *properly* this time; better error handling for DB gets

This commit is contained in:
ari melody 2025-11-08 15:04:07 +00:00
parent a33e6717e0
commit b7c1d85830
Signed by: ari
GPG key ID: CF99829C92678188
16 changed files with 234 additions and 288 deletions

View file

@ -66,10 +66,6 @@ func ServeBlog(app *model.AppState) http.Handler {
blog, err := controller.GetBlogPost(app.DB, blogID)
if err != nil {
if strings.Contains(err.Error(), "no rows") {
http.NotFound(w, r)
return
}
fmt.Fprintf(os.Stderr, "WARN: Failed to fetch blog post %s: %v\n", blogID, err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
@ -150,10 +146,6 @@ func UpdateBlog(app *model.AppState) http.Handler {
blog, err := controller.GetBlogPost(app.DB, blogID)
if err != nil {
if strings.Contains(err.Error(), "no rows") {
http.NotFound(w, r)
return
}
fmt.Fprintf(os.Stderr, "WARN: Failed to fetch blog post %s: %v\n", blogID, err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
@ -212,10 +204,6 @@ func UpdateBlog(app *model.AppState) http.Handler {
err = controller.UpdateBlogPost(app.DB, blogID, blog)
if err != nil {
if strings.Contains(err.Error(), "no rows") {
http.NotFound(w, r)
return
}
fmt.Printf("WARN: Failed to update release %s: %v\n", blogID, err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}