Skip to content

Commit 49169b7

Browse files
committed
try to capture bad row warning more cleanly
1 parent 5d69533 commit 49169b7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

astroquery/exceptions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
__all__ = ['TimeoutError', 'InvalidQueryError', 'RemoteServiceError',
99
'TableParseError', 'LoginError', 'ResolverError',
1010
'NoResultsWarning', 'LargeQueryWarning', 'InputWarning',
11-
'AuthenticationWarning', 'MaxResultsWarning', 'CorruptDataWarning']
11+
'AuthenticationWarning', 'MaxResultsWarning', 'CorruptDataWarning',
12+
'BadRowWarning']
1213

1314

1415
class TimeoutError(Exception):
@@ -111,3 +112,11 @@ class EmptyResponseError(ValueError):
111112
Astroquery error class to be raised when the query returns an empty result
112113
"""
113114
pass
115+
116+
117+
class BadRowWarning(AstropyWarning):
118+
"""
119+
Astroquery warning to be raised if one or more rows in a table are bad, but
120+
not all rows are.
121+
"""
122+
pass

astroquery/simbad/tests/test_simbad_remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from astroquery.simbad import Simbad
1111
# Maybe we need to expose SimbadVOTableResult to be in the public API?
1212
from astroquery.simbad.core import SimbadVOTableResult
13+
from astroquery.exceptions import BadRowWarning
1314

1415

1516
# M42 coordinates
@@ -148,7 +149,8 @@ def test_query_multi_object(self, temp_dir):
148149
assert len(result) == 2
149150
assert len(result.errors) == 0
150151

151-
result = simbad.query_objects(['M32', 'M81', 'gHer'])
152+
with pytest.warns(BadRowWarning):
153+
result = simbad.query_objects(['M32', 'M81', 'gHer'])
152154
# 'gHer' is not a valid Simbad identifier - it should be 'g Her' to
153155
# get the star
154156
assert len(result) == 2

0 commit comments

Comments
 (0)