From a6c978eaee845f9e8e89358cffbb397a05dedf5e Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sat, 9 Dec 2023 14:39:02 +0100 Subject: [PATCH] Improve output of errors --- filesmap.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/filesmap.go b/filesmap.go index fd6683d..da273da 100644 --- a/filesmap.go +++ b/filesmap.go @@ -1,9 +1,10 @@ package main import ( + "errors" "flag" "fmt" - "log" + "image" "os" "path/filepath" "sync" @@ -61,7 +62,7 @@ func (fm *FilesMap) FileHashingWorker(wg *sync.WaitGroup) { fm.FilesHashed <- file if err != nil { - log.Printf("Error calculating Hash file for %s: %v\n", file.path, err) + fmt.Fprintf(fm.progress, "Error calculating Hash for file %s: %v\n", file.path, err) continue } @@ -79,8 +80,10 @@ func (fm *FilesMap) ImageHashingWorker(wg *sync.WaitGroup) { hash, err := calculateImageHash(file.path) fm.imageHashingBar.IncrInt64(file.size) - if err != nil { - log.Printf("Error calculating Hash for image %s: %v\n", file.path, err) + if errors.Is(err, image.ErrFormat) { + continue + } else if err != nil { + fmt.Fprintf(fm.progress, "Error calculating Hash for image %s: %v\n", file.path, err) continue }