mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +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()
|
bar.Close()
|
||||||
|
|
||||||
if len(images) == 0 {
|
if len(images) == 0 {
|
||||||
return nil, fmt.Errorf("image not found")
|
return nil, errNoImagesFound
|
||||||
}
|
}
|
||||||
|
|
||||||
return images, nil
|
return images, nil
|
||||||
|
@ -3,6 +3,7 @@ package epubimageprocessing
|
|||||||
import (
|
import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@ -27,6 +28,8 @@ type Options struct {
|
|||||||
Image *epubimage.Options
|
Image *epubimage.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errNoImagesFound = errors.New("no images found")
|
||||||
|
|
||||||
func (o *Options) mustExtractImage(imageOpener func() (io.ReadCloser, error)) *bytes.Buffer {
|
func (o *Options) mustExtractImage(imageOpener func() (io.ReadCloser, error)) *bytes.Buffer {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
if o.Dry {
|
if o.Dry {
|
||||||
@ -70,7 +73,7 @@ func (o *Options) loadDir() (totalImages int, output chan *tasks, err error) {
|
|||||||
totalImages = len(images)
|
totalImages = len(images)
|
||||||
|
|
||||||
if totalImages == 0 {
|
if totalImages == 0 {
|
||||||
err = fmt.Errorf("image not found")
|
err = errNoImagesFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +118,7 @@ func (o *Options) loadCbz() (totalImages int, output chan *tasks, err error) {
|
|||||||
|
|
||||||
if totalImages == 0 {
|
if totalImages == 0 {
|
||||||
r.Close()
|
r.Close()
|
||||||
err = fmt.Errorf("no images found")
|
err = errNoImagesFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +179,7 @@ func (o *Options) loadCbr() (totalImages int, output chan *tasks, err error) {
|
|||||||
|
|
||||||
totalImages = len(names)
|
totalImages = len(names)
|
||||||
if totalImages == 0 {
|
if totalImages == 0 {
|
||||||
err = fmt.Errorf("no images found")
|
err = errNoImagesFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user