Skip to content

Commit cf93bfa

Browse files
committed
add response code fix while solr is down
1 parent 882f16b commit cf93bfa

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

ckan/lib/search/query.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,16 @@ def _check_query_parser(param: str, value: Any):
469469
'Unknown sort order' in e.args[0]:
470470
raise SearchQueryError('Invalid "sort" parameter')
471471

472-
if "Failed to connect to server" in e.args[0]:
473-
log.warning("Connection Error: Failed to connect to Solr server.")
472+
if "Failed to connect to server" in e.args[0] or \
473+
"Connection to server" in e.args[0]:
474+
log.error("Connection Error: Failed to connect to Solr server.")
475+
raise SolrConnectionError("Solr returned an error while searching.")
476+
477+
if "(HTTP 504)" in e.args[0] or \
478+
"(HTTP 503)" in e.args[0] or \
479+
"(HTTP 502)" in e.args[0] or \
480+
"(HTTP 401)" in e.args[0]:
481+
log.error(f"Connection Error: {e.args[0]}")
474482
raise SolrConnectionError("Solr returned an error while searching.")
475483

476484
raise SearchError('SOLR returned an error running query: %r Error: %r' %

0 commit comments

Comments
 (0)