protected virtual void CheckSemanticErrors(DeveroomGherkinDocument specFlowDocument)
        {
            var errors = new List <ParserException>();

            errors.AddRange(((DeveroomGherkinAstBuilder)_astBuilder).Errors);

            if (specFlowDocument?.Feature != null)
            {
                CheckForDuplicateScenarios(specFlowDocument.Feature, errors);

                CheckForDuplicateExamples(specFlowDocument.Feature, errors);

                CheckForMissingExamples(specFlowDocument.Feature, errors);

                CheckForRulesPreSpecFlow31(specFlowDocument.Feature, errors);
            }

            // collect
            if (errors.Count == 1)
            {
                throw errors[0];
            }
            if (errors.Count > 1)
            {
                throw new CompositeParserException(errors.ToArray());
            }
        }
        public bool ParseAndCollectErrors(string featureFileContent, IDeveroomLogger logger, out DeveroomGherkinDocument gherkinDocument, out List <ParserException> parserErrors)
        {
            var reader = new StringReader(featureFileContent);

            gherkinDocument = null;
            parserErrors    = new List <ParserException>();
            try
            {
                gherkinDocument = Parse(reader, "foo.feature"); //TODO: remove unused path
                return(true);
            }
            catch (ParserException parserException)
            {
                logger.LogVerbose($"ParserErrors: {parserException.Message}");
                gherkinDocument = GetResultOfInvalid();
                if (parserException is CompositeParserException compositeParserException)
                {
                    parserErrors.AddRange(compositeParserException.Errors);
                }
                else
                {
                    parserErrors.Add(parserException);
                }
            }
            catch (Exception e)
            {
                logger.LogException(_monitoringService, e, "Exception during Gherkin parsing");
                gherkinDocument = GetResult();
            }
            return(false);
        }