From d7869a1f0ed7915e0dd11bb51c49959d0b973315 Mon Sep 17 00:00:00 2001 From: John Nduli Date: Thu, 4 Jul 2024 19:24:06 +0300 Subject: fix: return query error message from xapian --- gn3/api/search.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/search.py b/gn3/api/search.py index 588e11d..7242ac1 100644 --- a/gn3/api/search.py +++ b/gn3/api/search.py @@ -268,8 +268,10 @@ def search_results(): maximum_results_per_page = 50000 if results_per_page > maximum_results_per_page: abort(400, description="Requested too many search results") - - query = parse_query(Path(current_app.config["DATA_DIR"]) / "synteny", querystring) + try: + query = parse_query(Path(current_app.config["DATA_DIR"]) / "synteny", querystring) + except xapian.QueryParserError as err: + return jsonify({"error_type": str(err.get_type()), "error": err.get_msg()}), 400 traits = [] # pylint: disable=invalid-name with xapian_database(current_app.config["XAPIAN_DB_PATH"]) as db: -- cgit v1.2.3