From 453dd7f8ecdcf678e5d068d2c838c73b7ecac448 Mon Sep 17 00:00:00 2001 From: Fuhu Xia Date: Fri, 30 Aug 2024 12:35:06 -0400 Subject: [PATCH] capture more generic error message --- ckan/lib/search/query.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ckan/lib/search/query.py b/ckan/lib/search/query.py index ecae0292231..19b674a561f 100644 --- a/ckan/lib/search/query.py +++ b/ckan/lib/search/query.py @@ -479,13 +479,11 @@ def _check_query_parser(param: str, value: Any): log.error("Connection Error: Failed to connect to Solr server.") raise SolrConnectionError("Solr returned an error while searching.") - if "Error 401 Bad credentials" in e.args[0]: - log.error("Connection Error: 401 Bad credentials.") - raise SolrConnectionError("Solr returned an error while searching.") - - - if "503 Service Temporarily Unavailable" in e.args[0]: - log.error("Connection Error: 503 Service Temporarily Unavailable.") + if "(HTTP 504)" in e.args[0] or \ + "(HTTP 503)" in e.args[0] or \ + "(HTTP 502)" in e.args[0] or \ + "(HTTP 401)" in e.args[0]: + log.error(f"Connection Error: {e.args[0]}") raise SolrConnectionError("Solr returned an error while searching.") raise SearchError('SOLR returned an error running query: %r Error: %r' %