Skip to content

Commit d92a0e8

Browse files
committed
add more informative exception and regression test
1 parent 4c9edf7 commit d92a0e8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

astroquery/vizier/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def find_catalogs(self, keywords, include_obsolete=False, verbose=False,
169169
url=self._server_to_url(),
170170
data=data_payload,
171171
timeout=self.TIMEOUT)
172+
if 'STOP, Max. number of RESOURCE reached' in response.content:
173+
raise ValueError("Maximum number of catalogs exceeded. Try setting max_catalogs "
174+
"to a large number and try again")
172175
result = self._parse_result(response, verbose=verbose, get_catalog_names=True)
173176

174177
# Filter out the obsolete catalogs, unless requested

astroquery/vizier/tests/test_vizier_remote.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@ def test_multicoord(self):
7979
assert len(result) >= 5
8080
assert 'I/239/hip_main' in result.keys()
8181
assert result['I/239/hip_main']['HIP'] == 98298
82+
83+
def test_findcatalog_maxcatalog(self):
84+
V = Vizier()
85+
cats = Vizier.find_catalogs('eclipsing binary', max_catalogs=5000)
86+
assert len(cats) >= 468
87+
88+
with pytest.raises(ValueError) as exc:
89+
Vizier.find_catalogs('eclipsing binary')
90+
assert str(exc.value)==("Maximum number of catalogs exceeded."
91+
" Try setting max_catalogs "
92+
"to a large number and try again")
93+

0 commit comments

Comments
 (0)