diff --git a/internal/epub/image_processing/epub_image_processing.go b/internal/epub/image_processing/epub_image_processing.go index cf14009..2aa1d70 100644 --- a/internal/epub/image_processing/epub_image_processing.go +++ b/internal/epub/image_processing/epub_image_processing.go @@ -172,7 +172,7 @@ func LoadImages(o *Options) ([]*epubimage.Image, error) { bar.Close() if len(images) == 0 { - return nil, fmt.Errorf("image not found") + return nil, errNoImagesFound } return images, nil diff --git a/internal/epub/image_processing/epub_image_processing_loader.go b/internal/epub/image_processing/epub_image_processing_loader.go index 69a9d39..b19c2d5 100644 --- a/internal/epub/image_processing/epub_image_processing_loader.go +++ b/internal/epub/image_processing/epub_image_processing_loader.go @@ -3,6 +3,7 @@ package epubimageprocessing import ( "archive/zip" "bytes" + "errors" "fmt" "io" "io/fs" @@ -27,6 +28,8 @@ type Options struct { Image *epubimage.Options } +var errNoImagesFound = errors.New("no images found") + func (o *Options) mustExtractImage(imageOpener func() (io.ReadCloser, error)) *bytes.Buffer { var b bytes.Buffer if o.Dry { @@ -70,7 +73,7 @@ func (o *Options) loadDir() (totalImages int, output chan *tasks, err error) { totalImages = len(images) if totalImages == 0 { - err = fmt.Errorf("image not found") + err = errNoImagesFound return } @@ -115,7 +118,7 @@ func (o *Options) loadCbz() (totalImages int, output chan *tasks, err error) { if totalImages == 0 { r.Close() - err = fmt.Errorf("no images found") + err = errNoImagesFound return } @@ -176,7 +179,7 @@ func (o *Options) loadCbr() (totalImages int, output chan *tasks, err error) { totalImages = len(names) if totalImages == 0 { - err = fmt.Errorf("no images found") + err = errNoImagesFound return }