jameslittle230 / stork

🔎 Impossibly fast web search, made for static sites.
https://stork-search.net
Apache License 2.0
2.73k stars 56 forks source link

Confusing error message if HTML selector does not match the document for a single document config #268

Closed ankrgyl closed 2 years ago

ankrgyl commented 2 years ago

I was trying to index an HTML document which does not have a main tag, and the error message looks something like this:

$ stork build --input basic.toml --output impira-docs.st
Error: No files could be indexed

Digging around a bit, it seems like IndexGenerationError::NoValidFiles doesn't retain the context for why there are no valid files. However, if you have at least one valid file in the ToML file, then you get a more helpful error:

Warning: Stork couldn't include 1 file in the index because of the following errors:
In file `foo.html`: The selector `main` is not present in the HTML document.

Would it be possible to include this more helpful reason in the first case as well? I'd be happy to contribute a fix (with some guidance around the ideal solution), but I'm new to the project so figured I'd ask here first.

jameslittle230 commented 2 years ago

Good call - thanks for the comprehensive report. Stork has, in the past, done a better job of displaying the errors it encountered if it couldn't parse any files, but I think there was a regression somewhere along the way.

I'll get to this before releasing the next version.

Best, James

ankrgyl commented 2 years ago

Awesome, thank you!