diff --git a/CHANGES.rst b/CHANGES.rst index 15c4c47eb5..46761a7ced 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -48,6 +48,12 @@ esa.jwst - Add download_files_from_program method to get all products by program id [#3073] +ipac.irsa +^^^^^^^^^ + +- Add more robust handling of errors returned in Most.query_object() responses. + [#3140] + mpc ^^^ diff --git a/astroquery/ipac/irsa/most.py b/astroquery/ipac/irsa/most.py index d46afb1940..ef136a10e7 100644 --- a/astroquery/ipac/irsa/most.py +++ b/astroquery/ipac/irsa/most.py @@ -189,6 +189,11 @@ def _parse_full_regular_response(self, response, withTarballs=False): html = BeautifulSoup(response.content, "html5lib") download_tags = html.find_all("a", string=re.compile(".*Download.*")) + # If for some reason this wasn't a full response with downloadable tags, + # raise an explicit exception: + if not download_tags: + raise ValueError('Something has gone wrong, there are no results parsed. ' + f'For full response see: {response.text}') # this is "Download Results Table (above)" results_response = self._request("GET", download_tags[0]["href"]) retdict["results"] = Table.read(results_response.text, format="ipac") @@ -532,7 +537,7 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod # MOST will not raise an bad response if the query is bad because they # are not a REST API - if "MOST: *** error:" in response.text: + if "MOST: *** error:" in response.text or "most: error:" in response.text: raise InvalidQueryError(response.text) # presume that response is HTML to simplify conditions