Skip to content

Commit

Permalink
Merge pull request #3171 from mkelley/mpc-exception-format
Browse files Browse the repository at this point in the history
Format MPC ephemeris error response as text (i.e., strip HTML tags).
  • Loading branch information
bsipocz authored Jan 9, 2025
2 parents 23d3471 + ce16e78 commit 94dbe5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ mpc
- Remove ``comettype`` parameter from ``MPC.get_observations`` without
deprecation: it was undocumented, ignored, and had no effect. [#3089]

- When ``MPC.get_ephemeris`` raises an ``InvalidQueryError`` message, instead of
returning the original HTML formatted text, strip the HTML tags and return a
plain text message. [#3171]

nvas
^^^^

Expand Down
2 changes: 1 addition & 1 deletion astroquery/mpc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ def _parse_result(self, result, **kwargs):
content = result.content.decode()
table_start = content.find('<pre>')
if table_start == -1:
raise InvalidQueryError(content)
raise InvalidQueryError(BeautifulSoup(content, "html.parser").get_text())
table_end = content.find('</pre>')
text_table = content[table_start + 5:table_end]
SKY = 'raty=a' in result.request.body
Expand Down

0 comments on commit 94dbe5c

Please sign in to comment.