Skip to content

Improve error handling for erroneous URL #172

@hollisticated-horse

Description

@hollisticated-horse

Describe the bug
When trying to extract a bad URL for a comic book, the CLI throws a goroutine error. This does not help the user understand that they are using a non-valid comic book URL.

To Reproduce

NON VALID URL:

This is the link to a single issue in readallcomics.com

https://readallcomics.com/we-called-them-giants-2024/

Error message:

./comics-downloader -all -url=https://readallcomics.com/we-called-them-giants-2024/                                                                 
INFO[0001] Downloading...                               
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x810259]

goroutine 1 [running]:
github.com/anaskhan96/soup.findAllofem.func1(0x46fd5f?, {0xc000318210, 0x1, 0x1}, 0x39?)
	/home/nomade/go/pkg/mod/github.com/anaskhan96/soup@v1.2.5/soup.go:534 +0x1b9
github.com/anaskhan96/soup.findAllofem(0x0, {0xc000318210, 0x1, 0x1}, 0x0)
	/home/nomade/go/pkg/mod/github.com/anaskhan96/soup@v1.2.5/soup.go:538 +0xd8
github.com/anaskhan96/soup.Root.FindAll({0x0, {0x0, 0x0}, {0xa56400, 0xc000460678}}, {0xc000318210, 0x1, 0x1})
	/home/nomade/go/pkg/mod/github.com/anaskhan96/soup@v1.2.5/soup.go:283 +0x72
github.com/Girbons/comics-downloader/pkg/sites.(*Readallcomics).getIssues(0xc000194120, {0xc000470040, 0x3d})
	/tmp/comics-downloader/pkg/sites/readallcomics.go:64 +0x237
github.com/Girbons/comics-downloader/pkg/sites.(*Readallcomics).RetrieveIssueLinks(0xc000194120)
	/tmp/comics-downloader/pkg/sites/readallcomics.go:101 +0x145
github.com/Girbons/comics-downloader/pkg/sites.LoadComicFromSource(0xc0001c4300)
	/tmp/comics-downloader/pkg/sites/loader.go:119 +0x371
github.com/Girbons/comics-downloader/cmd/app.download(0xc0001c4300)
	/tmp/comics-downloader/cmd/app/downloader.go:83 +0x2ea
github.com/Girbons/comics-downloader/cmd/app.Run(0xc0001c4300)
	/tmp/comics-downloader/cmd/app/downloader.go:130 +0x1b3
main.main()
	/tmp/comics-downloader/cmd/downloader/main.go:97 +0x26b

VALID URL:
main comic book page

https://readallcomics.com/we-called-them-giants/

Expected behavior
A clear and consice error message that indicates that the URL does not lead to a valid comic page for downloading.

Desktop (please complete the following information):

  • OS: Archlinux
  • Version: Latest
  • Type: CLI

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions