Skip to content

Commit 634ef4e

Browse files
committed
Only avoid caching HTTP errored queries.
1 parent e108972 commit 634ef4e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

astroquery/jplhorizons/core.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import warnings
1010

1111
# 2. third party imports
12+
from requests.exceptions import HTTPError
1213
from astropy.table import Table, Column
1314
from astropy.io import ascii
1415
from astropy.time import Time
@@ -1337,19 +1338,18 @@ def _parse_result(self, response, verbose=None):
13371338
"""
13381339

13391340
self.last_response = response
1340-
if self.query_type not in ['ephemerides', 'elements', 'vectors']:
1341-
return None
1342-
else:
1341+
try:
1342+
response.raise_for_status()
1343+
except HTTPError:
1344+
# don't cache any HTTP errored queries (especially when the API is down!)
13431345
try:
1344-
data = self._parse_horizons(response.text)
1345-
except Exception as ex:
1346-
try:
1347-
self._last_query.remove_cache_file(self.cache_location)
1348-
except OSError:
1349-
# this is allowed: if `cache` was set to False, this
1350-
# won't be needed
1351-
pass
1352-
raise
1346+
self._last_query.remove_cache_file(self.cache_location)
1347+
except OSError:
1348+
# this is allowed: if `cache` was set to False, this
1349+
# won't be needed
1350+
pass
1351+
raise
1352+
data = self._parse_horizons(response.text)
13531353
return data
13541354

13551355

0 commit comments

Comments
 (0)