feat: improve logging of errors in source ID handler
1 file changed, 17 insertions(+), 0 deletions(-)
changed files
M internal/server/mux.go → internal/server/mux.go
@@ -26,6 +26,7 @@ "alin.ovh/x/log" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fctx" "github.com/Southclaws/fault/fmsg" + "github.com/Southclaws/fault/ftag" "github.com/osdevisnot/sorvor/pkg/livereload" )@@ -234,6 +235,22 @@ importerSingular := importerType.Singular() doc, err := store.GetDocument(source, r.PathValue("id")) if err != nil { + if ftag.Get(err) == ftag.NotFound { + log.Warn("document not found", "source", source.Key, "id", r.PathValue("id")) + errorHandler(w, r, http.StatusText(http.StatusNotFound), http.StatusNotFound) + + return + } + + log.Error( + "failed to get document", + "source", + source.Key, + "id", + r.PathValue("id"), + "error", + err, + ) errorHandler( w, r,