Fix error format in log.Printf calls

This commit is contained in:
Peter Stuifzand 2021-08-08 23:43:40 +02:00
parent da1feee2a2
commit d50857c528

View File

@ -117,7 +117,7 @@ func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for _, page := range pages { for _, page := range pages {
err = saveBlocksFromPage("data", page) err = saveBlocksFromPage("data", page)
if err != nil { if err != nil {
log.Printf("error while processing blocks from page %s: %w", page.Name, err) log.Printf("error while processing blocks from page %s: %v", page.Name, err)
continue continue
} }
} }
@ -141,7 +141,7 @@ func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Println("saveLinks") log.Println("saveLinks")
err = saveLinks(mp) err = saveLinks(mp)
if err != nil { if err != nil {
log.Printf("error while saving links %w", err) log.Printf("error while saving links %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
@ -149,14 +149,14 @@ func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Println("saveBackrefs") log.Println("saveBackrefs")
err = saveBackrefs("data/backrefs.json", refs) err = saveBackrefs("data/backrefs.json", refs)
if err != nil { if err != nil {
log.Printf("error while saving backrefs %w", err) log.Printf("error while saving backrefs %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
err = os.RemoveAll("data/_tmp_index") err = os.RemoveAll("data/_tmp_index")
if err != nil { if err != nil {
log.Printf("error while remove old index %w", err) log.Printf("error while remove old index %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
@ -170,14 +170,14 @@ func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for _, page := range pages { for _, page := range pages {
searchObjects, err := createSearchObjects(page.Name) searchObjects, err := createSearchObjects(page.Name)
if err != nil { if err != nil {
log.Printf("error while creating search object %s: %w", page.Title, err) log.Printf("error while creating search object %s: %v", page.Title, err)
continue continue
} }
for _, so := range searchObjects { for _, so := range searchObjects {
err = index.Index(so.ID, so) err = index.Index(so.ID, so)
if err != nil { if err != nil {
log.Printf("error while indexing %s: %w", page.Title, err) log.Printf("error while indexing %s: %v", page.Title, err)
continue continue
} }
} }
@ -185,19 +185,19 @@ func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
err = os.Rename("data/_page-index", "data/_page-index-old") err = os.Rename("data/_page-index", "data/_page-index-old")
if err != nil { if err != nil {
log.Printf("error while resetting index: %w", err) log.Printf("error while resetting index: %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
err = os.Rename("data/_tmp_index", "data/_page-index") err = os.Rename("data/_tmp_index", "data/_page-index")
if err != nil { if err != nil {
log.Printf("error while putthing new index in place: %w", err) log.Printf("error while putthing new index in place: %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
err = os.RemoveAll("data/_page-index-old") err = os.RemoveAll("data/_page-index-old")
if err != nil { if err != nil {
log.Printf("error while remove old index %w", err) log.Printf("error while remove old index %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }