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(); + } }