From 59dd4d3124c10fb396d51cc1e9cdea722ac508af Mon Sep 17 00:00:00 2001 From: sb-cecilialiu Date: Tue, 17 Dec 2024 11:30:27 -0600 Subject: [PATCH] MAT-7995 filter out err msg when define lacks name --- .../filters/CqlTranslatorExceptionFilter.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/service/filters/CqlTranslatorExceptionFilter.java b/src/main/java/gov/cms/mat/cql_elm_translation/service/filters/CqlTranslatorExceptionFilter.java index 7fc9335f..5212f460 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/service/filters/CqlTranslatorExceptionFilter.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/service/filters/CqlTranslatorExceptionFilter.java @@ -48,11 +48,17 @@ public List filter() { filteredList = filterBySyntax(filteredCqlTranslatorExceptions); if (CollectionUtils.isNotEmpty(filteredList)) { - newList.addAll(filteredList); + newList.addAll(filterOutCustomErrors(filteredList)); } return newList; } + /* + * MAT-7995: error: "No Viable Input at 'define :'" + * should be customized as: "Definition is missing a name." + * This is done in cql-antlr-parse, so on the frontend we don't want a duplicate error message + * therefore we are filtering it out here. + */ private List filterOutWarnings() { if (showWarnings) { return cqlTranslatorExceptions; @@ -111,4 +117,14 @@ private List filterBySyntax( .contains("org.cqframework.cql.cql2elm.CqlSyntaxException")) .toList(); } + + private List filterOutCustomErrors( + List filteredCqlTranslatorExceptions) { + return filteredCqlTranslatorExceptions.stream() + .filter( + cqlCompilerException -> + !"no viable alternative at input 'define :'" + .equalsIgnoreCase(cqlCompilerException.getMessage())) + .toList(); + } }