Skip to content

Commit af6b592

Browse files
committed
expand error coverage
1 parent afd1ac0 commit af6b592

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

astroquery/atomic/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,14 @@ def _parse_result(self, response):
251251

252252
if 'ERROR: request form contains no information' in response.text:
253253
raise ValueError(f"The server returned an error. Please check the URL. The full error message is {response.text}")
254+
elif 'ERROR' in response.text:
255+
raise ValueError(f"The server returned an error. The full error message is {response.text}")
254256

255-
data = StringIO(BeautifulSoup(response.text, features='html5lib').find('pre').text.strip())
257+
html_pre = BeautifulSoup(response.text, features='html5lib').find('pre')
258+
if html_pre is None:
259+
raise ValueError("Data format not recognized. The <pre> tag was missing from the response.")
260+
261+
data = StringIO(html_pre.text.strip())
256262
# `header` is e.g.:
257263
# "u'-LAMBDA-VAC-ANG-|-SPECTRUM--|TT|--------TERM---------|---J-J---|----LEVEL-ENERGY--CM-1----'"
258264
# `colnames` is then

0 commit comments

Comments
 (0)