diff --git a/app/corpora/CQiWrapper/CQiClient.py b/app/corpora/CQiWrapper/CQiClient.py
index 3656cad8..761a8739 100644
--- a/app/corpora/CQiWrapper/CQiClient.py
+++ b/app/corpora/CQiWrapper/CQiClient.py
@@ -368,7 +368,7 @@ class CQiClient:
self.__send_STRING(mother_corpus)
self.__send_STRING(subcorpus_name)
self.__send_STRING(query)
- self.__recv_WORD()
+ self.__recv_response()
def cqp_list_subcorpora(self, corpus):
# INPUT: (STRING corpus)
@@ -464,6 +464,8 @@ class CQiClient:
response = byte_data
elif response_type == CQi.ERROR:
raise Exception(CQi.lookup[byte_data])
+ elif response_type == CQi.ERROR_SYNTAX_ERROR:
+ raise Exception(CQi.lookup[byte_data])
elif response_type == CQi.DATA:
response = self.__recv_DATA(byte_data)
elif response_type == CQi.CL_ERROR:
diff --git a/app/corpora/events.py b/app/corpora/events.py
index d61fa1a4..46bcfe3b 100644
--- a/app/corpora/events.py
+++ b/app/corpora/events.py
@@ -49,12 +49,17 @@ def corpus_analysis(message):
context_len = int(message['context'])
result_offset = 0
client.select_corpus(corpus_name)
- client.query_subcorpus(query)
- results = client.show_query_results(result_len=result_len,
- context_len=context_len,
- result_offset=result_offset)
+ try:
+ client.query_subcorpus(query)
+ except Exception as e:
+ logger.warning(e)
+ socketio.emit('corpus_analysis', str(e), room=request.sid)
+ else:
+ results = client.show_query_results(result_len=result_len,
+ context_len=context_len,
+ result_offset=result_offset)
- socketio.emit('corpus_analysis', results, room=request.sid)
+ socketio.emit('corpus_analysis', results, room=request.sid)
@socketio.on('inspect_match')
diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2
index f32daeb8..bd48e441 100644
--- a/app/templates/corpora/analyse_corpus.html.j2
+++ b/app/templates/corpora/analyse_corpus.html.j2
@@ -258,7 +258,17 @@
});
}
return;
- }
+ } else if (message === "CQI_CQP_ERROR_GENERAL") {
+ queryResultsTableElement.classList.add("hide");
+ let toast = M.toast({"classes": "red", "html": `Invalid query entered!`});
+ let toastActionElement = toast.el.querySelector(".toast-action[data-action='close']");
+ if (toastActionElement) {
+ toastActionElement.addEventListener("click", function() {
+ toast.dismiss();
+ });
+ }
+ return;
+ }
var matchElement;
var matchTextTitlesElement;