detect 404s

This commit is contained in:
r4 2021-07-20 16:14:19 +02:00
parent 147988315d
commit 7abed7640b
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,7 @@ var (
ErrInvalidURL = errors.New("invalid url")
ErrNoChaptersFound = errors.New("no chapters found in index")
ErrParsingPage = errors.New("error parsing page")
ErrBookNotFound = errors.New("book not found")
)
const (
@ -145,6 +146,9 @@ func (e *Extractor) FetchAndProcessIndex() error {
if err != nil {
return err
}
if resp.StatusCode == 404 {
return ErrBookNotFound
}
defer resp.Body.Close()
// Parse HTML via Goquery.
doc, err := gq.NewDocumentFromReader(resp.Body)