From 745b7180204d479e4425d5fa179234e0f1258c81 Mon Sep 17 00:00:00 2001 From: Tomas Machalek Date: Thu, 17 Oct 2024 15:14:49 +0200 Subject: [PATCH] Feature - save queries with syntax err to make them appear in history --- lib/views/concordance.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/views/concordance.py b/lib/views/concordance.py index d17f61f6d..9d71a40b8 100644 --- a/lib/views/concordance.py +++ b/lib/views/concordance.py @@ -59,7 +59,7 @@ from conclib.errors import ( ConcordanceException, ConcordanceQueryParamsError, ConcordanceSpecificationError, UnknownConcordanceAction, - extract_manatee_error) + ConcordanceQuerySyntaxError, extract_manatee_error) from conclib.freq import one_level_crit from conclib.search import get_conc from corplib.abstract import SubcorpusIdent @@ -167,6 +167,12 @@ async def store_last_op(conc_ids: List[str], history_ts: Optional[int], _): ans['finished'] = conc.finished() amodel.on_query_store(store_last_op) resp.set_http_status(201) + except ConcordanceQuerySyntaxError as ex: + # we want queries with syntax errors to be saved, so we suppress + # the error a bit to make amodel.post_dispatch do its work + ans['size'] = 0 + ans['finished'] = True + resp.add_system_message('error', str(ex)) except (ConcordanceException, ConcCacheStatusException) as ex: ans['size'] = 0 ans['finished'] = True