Search in sources :

Example 1 with ParserException

use of gherkin.ParserException in project cucable-plugin by trivago.

the class GherkinDocumentParser method getGherkinDocumentFromFeatureFileContent.

/**
 * Get a {@link GherkinDocument} from a feature file for further processing.
 *
 * @param featureContent a feature string.
 * @return a {@link GherkinDocument}.
 * @throws CucablePluginException see {@link CucablePluginException}.
 */
private GherkinDocument getGherkinDocumentFromFeatureFileContent(final String featureContent) throws CucablePluginException {
    Parser<GherkinDocument> gherkinDocumentParser = new Parser<>(new AstBuilder());
    GherkinDocument gherkinDocument;
    try {
        gherkinDocument = gherkinDocumentParser.parse(featureContent);
    } catch (ParserException parserException) {
        throw new CucablePluginException("Could not parse feature!");
    }
    if (gherkinDocument == null || gherkinDocument.getFeature() == null) {
        throw new CucablePluginException("Could not parse feature!");
    }
    return gherkinDocument;
}
Also used : AstBuilder(gherkin.AstBuilder) ParserException(gherkin.ParserException) CucablePluginException(com.trivago.rta.exceptions.CucablePluginException) GherkinDocument(gherkin.ast.GherkinDocument) Parser(gherkin.Parser)

Example 2 with ParserException

use of gherkin.ParserException in project cucable-plugin by trivago.

the class GherkinDocumentParser method getGherkinDocumentFromFeatureFileContent.

/**
 * Get a {@link GherkinDocument} from a feature file for further processing.
 *
 * @param featureContent a feature string.
 * @return a {@link GherkinDocument}.
 * @throws CucablePluginException see {@link CucablePluginException}.
 */
private GherkinDocument getGherkinDocumentFromFeatureFileContent(final String featureContent) throws CucablePluginException {
    Parser<GherkinDocument> gherkinDocumentParser = new Parser<>(new AstBuilder());
    GherkinDocument gherkinDocument;
    try {
        gherkinDocument = gherkinDocumentParser.parse(featureContent);
    } catch (ParserException parserException) {
        throw new CucablePluginException(parserException.getMessage());
    }
    if (gherkinDocument == null || gherkinDocument.getFeature() == null) {
        cucableLogger.warn("No parsable gherkin.");
    }
    return gherkinDocument;
}
Also used : AstBuilder(gherkin.AstBuilder) ParserException(gherkin.ParserException) CucablePluginException(com.trivago.exceptions.CucablePluginException) GherkinDocument(gherkin.ast.GherkinDocument) TagExpressionParser(io.cucumber.tagexpressions.TagExpressionParser) Parser(gherkin.Parser)

Aggregations

AstBuilder (gherkin.AstBuilder)2 Parser (gherkin.Parser)2 ParserException (gherkin.ParserException)2 GherkinDocument (gherkin.ast.GherkinDocument)2 CucablePluginException (com.trivago.exceptions.CucablePluginException)1 CucablePluginException (com.trivago.rta.exceptions.CucablePluginException)1 TagExpressionParser (io.cucumber.tagexpressions.TagExpressionParser)1