lukasschwab / arxiv.py

Python wrapper for the arXiv API
MIT License
1.07k stars 120 forks source link

Include feed in errors representing non-200 responses #75

Closed lukasschwab closed 3 years ago

lukasschwab commented 3 years ago

Motivation

A clear and concise description of what the problem is. For example, "I'm always frustrated when..."

arXiv (sometimes?) includes a valid Atom feed explaining non-200 responses. For example, see #74.

Solution

A clear and concise description of what you want to happen.

_parse_feed should make a best-effort at parsing the response body when it's about to raise an HTTPError.

If it's available, include that response body in the HTTPError and in that error's representations.

Considered alternatives

A clear and concise description of any alternative solutions or features you've considered.

N/A

Additional context

Add any other context about the feature request here.

There's an open question: if a body is available, and it's a valid feed, what should we do with it?

  1. Include it as a string; don't bother to parse the XML. Let the user determine how best to do that.
  2. Include it as a feedparser object.
  3. Parse with feedparser, but process the feed entries into differentiated errors.

I suspect the right approach is to begin with 1––just to start representing the dropped context to users––and then move on to step 3 if there are requests to differentiate HTTP errors programmatically.