mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 15:52:38 +02:00
factor error code
This commit is contained in:
parent
01d1670edd
commit
8a1eeb400d
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user