detect 404s
This commit is contained in:
parent
147988315d
commit
7abed7640b
4
main.go
4
main.go
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user