11
11
# import configurable items declared in __init__.py
12
12
from astroquery .linelists .cdms import conf
13
13
from astroquery .jplspec import lookup_table
14
+ from astroquery .exceptions import InvalidQueryError , EmptyResponseError
14
15
15
16
16
17
__all__ = ['CDMS' , 'CDMSClass' ]
@@ -104,7 +105,7 @@ def query_lines_async(self, min_frequency, max_frequency, *,
104
105
min_frequency = min_frequency .to (u .GHz , u .spectral ())
105
106
max_frequency = max_frequency .to (u .GHz , u .spectral ())
106
107
if min_frequency > max_frequency :
107
- raise ValueError ("min_frequency must be less than max_frequency" )
108
+ raise InvalidQueryError ("min_frequency must be less than max_frequency" )
108
109
109
110
payload ['MinNu' ] = min_frequency .value
110
111
payload ['MaxNu' ] = max_frequency .value
@@ -128,9 +129,9 @@ def query_lines_async(self, min_frequency, max_frequency, *,
128
129
payload ['Molecules' ] = tuple (f"{ val :06d} { key } "
129
130
for key , val in luts .items ())[0 ]
130
131
if len (molecule ) == 0 :
131
- raise ValueError ('No matching species found. Please '
132
- 'refine your search or read the Docs '
133
- 'for pointers on how to search.' )
132
+ raise InvalidQueryError ('No matching species found. Please '
133
+ 'refine your search or read the Docs '
134
+ 'for pointers on how to search.' )
134
135
else :
135
136
payload ['Molecules' ] = molecule
136
137
@@ -153,7 +154,7 @@ def query_lines_async(self, min_frequency, max_frequency, *,
153
154
ok = True
154
155
break
155
156
if not ok :
156
- raise ValueError ("Did not find table in response" )
157
+ raise EmptyResponseError ("Did not find table in response" )
157
158
158
159
baseurl = self .URL .split ('cgi-bin' )[0 ]
159
160
fullurl = f'{ baseurl } /{ url } '
@@ -203,7 +204,7 @@ def _parse_result(self, response, verbose=False):
203
204
"""
204
205
205
206
if 'Zero lines were found' in response .text :
206
- raise ValueError (f"Response was empty; message was '{ response .text } '." )
207
+ raise EmptyResponseError (f"Response was empty; message was '{ response .text } '." )
207
208
208
209
soup = BeautifulSoup (response .text , 'html.parser' )
209
210
text = soup .find ('pre' ).text
0 commit comments