Skip to content

Commit 7432733

Browse files
committed
update JPLspec exceptions and add new EmptyResponseError exception
1 parent 09c1f23 commit 7432733

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

astroquery/exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,10 @@ class MaxResultsWarning(AstropyWarning):
9696
results are returned.
9797
"""
9898
pass
99+
100+
101+
class EmptyResponseError(ValueError):
102+
"""
103+
Astroquery error class to be raised when the query returns an empty result
104+
"""
105+
pass

astroquery/jplspec/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# import configurable items declared in __init__.py
1010
from . import conf
1111
from . import lookup_table
12+
from astroquery.exceptions import EmptyResponseError, InvalidQueryError
1213

1314

1415
__all__ = ['JPLSpec', 'JPLSpecClass']
@@ -106,9 +107,9 @@ def query_lines_async(self, min_frequency, max_frequency,
106107
self.lookup_ids = build_lookup()
107108
payload['Mol'] = tuple(self.lookup_ids.find(molecule, flags).values())
108109
if len(molecule) == 0:
109-
raise ValueError('No matching species found. Please\
110-
refine your search or read the Docs\
111-
for pointers on how to search.')
110+
raise InvalidQueryError('No matching species found. Please '
111+
'refine your search or read the Docs '
112+
'for pointers on how to search.')
112113
else:
113114
payload['Mol'] = molecule
114115

@@ -157,7 +158,7 @@ def _parse_result(self, response, verbose=False):
157158
"""
158159

159160
if 'Zero lines were found' in response.text:
160-
raise ValueError(f"Response was empty; message was '{response.text}'.")
161+
raise EmptyResponseError(f"Response was empty; message was '{response.text}'.")
161162

162163
# data starts at 0 since regex was applied
163164
# Warning for a result with more than 1000 lines:

0 commit comments

Comments
 (0)