Added log messages for a few errors
This commit is contained in:
@@ -49,6 +49,7 @@ func (b *Backend) countLog(w http.ResponseWriter, r *http.Request) {
|
|||||||
ap := b.GetApp(hdr.Key)
|
ap := b.GetApp(hdr.Key)
|
||||||
count := ap.CountTable()
|
count := ap.CountTable()
|
||||||
if count == nil {
|
if count == nil {
|
||||||
|
log.Println(ap.AppID(), "misconfigured: count table is nil.")
|
||||||
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ func (b *Backend) managementDeleteCrash(w http.ResponseWriter, r *http.Request)
|
|||||||
func (b *Backend) actualCrashDelete(ctx context.Context, w http.ResponseWriter, ap App, crashID string) {
|
func (b *Backend) actualCrashDelete(ctx context.Context, w http.ResponseWriter, ap App, crashID string) {
|
||||||
crash := ap.CrashTable()
|
crash := ap.CrashTable()
|
||||||
if crash == nil {
|
if crash == nil {
|
||||||
|
log.Println(ap.AppID(), "misconfigured: crash table is nil.")
|
||||||
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -166,6 +167,7 @@ func (b *Backend) managementArchiveCrash(w http.ResponseWriter, r *http.Request)
|
|||||||
func (b *Backend) actualCrashArchive(ctx context.Context, w http.ResponseWriter, ap App, toArchive ArchivedCrash) {
|
func (b *Backend) actualCrashArchive(ctx context.Context, w http.ResponseWriter, ap App, toArchive ArchivedCrash) {
|
||||||
crash := ap.CrashTable()
|
crash := ap.CrashTable()
|
||||||
if crash == nil {
|
if crash == nil {
|
||||||
|
log.Println(ap.AppID(), "misconfigured: crash table is nil.")
|
||||||
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
ReturnError(w, http.StatusInternalServerError, "misconfigured", "Server Misconfigured")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ func (b *Backend) login(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
ret.Token, err = b.GenerateJWT(u.ToReqUser())
|
ret.Token, err = b.GenerateJWT(u.ToReqUser())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("error generating JWT token:", err)
|
||||||
ReturnError(w, http.StatusInternalServerError, "internal", "Server error")
|
ReturnError(w, http.StatusInternalServerError, "internal", "Server error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,14 +151,15 @@ func (b *BlogApp) updateAuthorInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
res, err := b.authCol.UpdateByID(r.Context(), r.PathValue("authorID"), actlUpd)
|
res, err := b.authCol.UpdateByID(r.Context(), r.PathValue("authorID"), actlUpd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == mongo.ErrNoDocuments {
|
if err == mongo.ErrNoDocuments {
|
||||||
backend.ReturnError(w, http.StatusNotFound, "notFound", "Blog with ID "+r.PathValue("blogID")+" not found")
|
backend.ReturnError(w, http.StatusNotFound, "notFound", "Author with ID "+r.PathValue("authorID")+" not found")
|
||||||
} else {
|
} else {
|
||||||
|
log.Println("error updating author", r.PathValue("authorID")+":", err)
|
||||||
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if res.MatchedCount == 0 {
|
if res.MatchedCount == 0 {
|
||||||
backend.ReturnError(w, http.StatusNotFound, "notFound", "Blog with ID "+r.PathValue("blogID")+" not found")
|
backend.ReturnError(w, http.StatusNotFound, "notFound", "Author with ID "+r.PathValue("authorID")+" not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ func (b *BlogApp) createBlog(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
id, err := uuid.NewV7()
|
id, err := uuid.NewV7()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("error generating UUID:", err)
|
||||||
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -247,6 +248,7 @@ func (b *BlogApp) updateBlog(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err == mongo.ErrNoDocuments {
|
if err == mongo.ErrNoDocuments {
|
||||||
backend.ReturnError(w, http.StatusNotFound, "notFound", "Blog with ID "+r.PathValue("blogID")+" not found")
|
backend.ReturnError(w, http.StatusNotFound, "notFound", "Blog with ID "+r.PathValue("blogID")+" not found")
|
||||||
} else {
|
} else {
|
||||||
|
log.Println("error updating blog", r.PathValue("blogID")+":", err)
|
||||||
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -120,6 +121,7 @@ func (b *BlogApp) Projects(ctx context.Context, techFilter string) (Portfolio, e
|
|||||||
func (b *BlogApp) reqPortfolio(w http.ResponseWriter, r *http.Request) {
|
func (b *BlogApp) reqPortfolio(w http.ResponseWriter, r *http.Request) {
|
||||||
folio, err := b.Projects(r.Context(), r.URL.Query().Get("tech"))
|
folio, err := b.Projects(r.Context(), r.URL.Query().Get("tech"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("error getting projects with filter", r.URL.Query().Get("tech")+":", err)
|
||||||
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user