SmartReader icon indicating copy to clipboard operation
SmartReader copied to clipboard

Reader.ParseArticle will raise weird HttpRequestException exception

Open doggy8088 opened this issue 1 year ago • 2 comments

For this code:

Article article = Reader.ParseArticle(url);

If request to the url returned HTTP 403 Forbidden, it will raise HttpRequestException exception. The exception object will contains a .StatusCude property but the value will be (null), and the .Message property will contains Cannot GET resource <URL>. StatusCode: Forbidden. That's not what I expected.

doggy8088 avatar Mar 26 '24 05:03 doggy8088

Thanks for reporting the issue. I will work on fixing it this weekend.

gabriele-tomassetti avatar Mar 27 '24 10:03 gabriele-tomassetti

There is an old issue related to this Exception: Raise a clear exception on non-successful http status code and document it. They wanted to have a custom SmartReader-based exception or document the current exception the library raises. We now document the exception.

However, maybe we should change the way we handle fail cases, given that a few people are surprised by our current approach. For instance, we could catch all exceptions and add some message to Article to indicate a failure in retrieving the article. What do you suggest? What would you want to happen instead of throwing an exception?

gabriele-tomassetti avatar Mar 30 '24 10:03 gabriele-tomassetti