|
1 | 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
|
2 | 2 |
|
3 |
| -from io import StringIO |
| 3 | +from io import StringIO, BytesIO |
4 | 4 |
|
5 |
| -from astropy.io import ascii |
| 5 | +from astropy.io import ascii, votable |
6 | 6 | import astropy.units as u
|
7 | 7 | from astropy.table import Table
|
| 8 | +from requests import HTTPError |
8 | 9 |
|
9 |
| -from . import conf |
10 |
| -from ..query import BaseQuery |
11 |
| -from ..utils import url_helpers, prepend_docstr_nosections, async_to_sync |
12 | 10 |
|
| 11 | +from astroquery.query import BaseQuery |
| 12 | +from astroquery.exceptions import InvalidQueryError |
| 13 | +from astroquery.utils import url_helpers, prepend_docstr_nosections, async_to_sync |
| 14 | + |
| 15 | +from . import conf |
13 | 16 | try:
|
14 | 17 | from regions import CircleSkyRegion
|
15 | 18 | except ImportError:
|
@@ -106,7 +109,12 @@ def query_async(self, cat1, cat2, max_distance, colRA1=None, colDec1=None,
|
106 | 109 |
|
107 | 110 | response = self._request(method='POST', url=self.URL, data=payload,
|
108 | 111 | timeout=self.TIMEOUT, cache=cache, **kwargs)
|
109 |
| - response.raise_for_status() |
| 112 | + try: |
| 113 | + response.raise_for_status() |
| 114 | + except HTTPError as err: |
| 115 | + error_votable = votable.parse(BytesIO(response.content)) |
| 116 | + error_reason = error_votable.get_info_by_id('QUERY_STATUS').content |
| 117 | + raise InvalidQueryError(error_reason) from err |
110 | 118 |
|
111 | 119 | return response
|
112 | 120 |
|
|
0 commit comments