Skip to content

Commit e447461

Browse files
committed
doc: make the error message state the two possible causes for failure
either the catalog is not available (no coordinates or typo in the name) or the user has to specify colRa and colDec
1 parent aeccd83 commit e447461

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ xmatch
286286
- Fix xmatch query for two local tables. The second table was written over the first one,
287287
resulting in a confusing "missing cat1" error. [#3116]
288288

289+
- Make the error message clearer about VizieR tables not available for
290+
crossmatching [#3168]
291+
289292

290293
0.4.7 (2024-03-08)
291294
==================

astroquery/xmatch/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ def _prepare_sending_table(self, cat_index, payload, kwargs, cat, colRA, colDec)
146146

147147
if not self.is_table_available(cat):
148148
if ((colRA is None) or (colDec is None)):
149-
raise ValueError('Specify the name of the RA/Dec columns in the input table.')
149+
raise ValueError(
150+
f"'{cat}' is not available on the XMatch server.If you are "
151+
"using a VizieR table name, note that only tables with "
152+
"coordinates are available on the XMatch server. If you are "
153+
f"using a local table, the arguments 'colRA{cat_index}' and "
154+
f"'colDec{cat_index}' must be provided.")
150155
# if `cat1` is not a VizieR table,
151156
# it is assumed it's either a URL or an uploaded table
152157
payload['colRA{0}'.format(cat_index)] = colRA

astroquery/xmatch/tests/test_xmatch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
from pathlib import Path
3+
import re
34

45
import requests
56
import pytest
@@ -114,3 +115,13 @@ def test_two_local_tables():
114115
max_distance=1 * arcsec,
115116
get_query_payload=True)
116117
assert 'cat1' in payload[1]["files"] and 'cat2' in payload[1]["files"]
118+
119+
120+
def test_table_not_available(monkeypatch):
121+
xm = XMatch()
122+
monkeypatch.setattr(xm, '_request', request_mockreturn)
123+
cat1 = "vizier:J/A+A/331/81/table2"
124+
cat2 = "blabla"
125+
# reproduces #1464
126+
with pytest.raises(ValueError, match=f"'{re.escape(cat1)}' is not available *"):
127+
xm.query_async(cat1=cat1, cat2=cat2, max_distance=5 * arcsec)

0 commit comments

Comments
 (0)