all repos — searchix @ 7f7515906b28675a38a9988eb25f9b5b527c9d95

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: improve logging of errors in source ID handler

Alan Pearce
commit

7f7515906b28675a38a9988eb25f9b5b527c9d95

parent

075a0a4a8bfd3dba66a5fbbf88b29d525c35c8be

1 file changed, 17 insertions(+), 0 deletions(-)

changed files
M internal/server/mux.gointernal/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,