Skip to content

Commit d5901aa

Browse files
committed
Handling no responses
1 parent d57559a commit d5901aa

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

astroquery/imcce/core.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
from io import BytesIO
77

88
from astropy.table import QTable, MaskedColumn
9-
from astropy.io import ascii
109
from astropy.time import Time
1110
from astropy.io.votable import parse
1211
import astropy.units as u
1312
from astropy.coordinates import SkyCoord, Angle
13+
from astropy.utils.exceptions import AstropyUserWarning
14+
15+
from astroquery.exceptions import NoResultsWarning
16+
from astroquery.query import BaseQuery
17+
from astroquery.utils import async_to_sync, commons
1418

15-
from ..query import BaseQuery
16-
from ..utils import async_to_sync, commons
1719
from . import conf
1820

1921
__all__ = ['Miriade', 'MiriadeClass', 'Skybot', 'SkybotClass']
@@ -611,6 +613,8 @@ def cone_search_async(self,
611613
params=request_payload,
612614
timeout=TIMEOUT, cache=cache)
613615

616+
response.raise_for_status()
617+
614618
self._uri = response.url
615619

616620
return response
@@ -622,14 +626,17 @@ def _parse_result(self, response, *, verbose=False):
622626

623627
if self._get_raw_response:
624628
return response.text
625-
import warnings
626-
from astropy.utils.exceptions import AstropyUserWarning
629+
627630
with warnings.catch_warnings():
628631
# We deal with RA/DEC manually
629632
warnings.filterwarnings("ignore", category=AstropyUserWarning,
630633
message=r"column ra|(column de) has a unit but is kept as a MaskedColumn")
631634
results = QTable.read(BytesIO(response.content), format='votable')
632635

636+
if len(results) == 0:
637+
warnings.warn("No objects were found with the query constraints.", NoResultsWarning)
638+
return results
639+
633640
# convert coordinates to degrees
634641
coo = SkyCoord(ra=results['ra'], dec=results['de'],
635642
unit=(u.hourangle, u.deg), frame='icrs')

0 commit comments

Comments
 (0)