use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.
the class AbstractSecurityRuleTranslator method withRule.
/**
* Set security pattern.
* @param securityRule security Pattern (not null, could be empty)
* @return this builder
*/
public final S withRule(final String securityRule) {
Assertion.checkNotNull(securityRule);
// -----
try {
final RuleMultiExpression myMultiExpression = DslParserUtil.parseMultiExpression(securityRule);
myMultiExpressions.add(myMultiExpression);
} catch (final PegNoMatchFoundException e) {
final String message = StringUtil.format("Echec de lecture de la securityRule {0}\n{1}", securityRule, e.getFullMessage());
throw WrappedException.wrap(e, message);
} catch (final Exception e) {
final String message = StringUtil.format("Echec de lecture de la securityRule {0}\n{1}", securityRule, e.getMessage());
throw WrappedException.wrap(e, message);
}
return (S) this;
}
use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.
the class KspLoader method load.
/**
* Chargement et analyse du fichier.
*
* @param dynamicModelrepository DynamicDefinitionRepository
*/
void load(final DslDefinitionRepository dynamicModelrepository) {
Assertion.checkNotNull(dynamicModelrepository);
try {
final String s = parseFile();
new DslKspRule(dynamicModelrepository).parse(s, 0);
} catch (final PegNoMatchFoundException e) {
final String message = StringUtil.format("Echec de lecture du fichier KSP {0}\n{1}", kspURL.getFile(), e.getFullMessage());
throw WrappedException.wrap(e, message);
} catch (final Exception e) {
final String message = StringUtil.format("Echec de lecture du fichier KSP {0}\n{1}", kspURL.getFile(), e.getMessage());
throw WrappedException.wrap(e, message);
}
}
use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest method testError.
@Test
public void testError() {
final List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Domain");
final String testValue = "{ dataType : String , formatter : FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ] , maxLengh:\"true\" } ";
try {
new DslDefinitionBodyRule(entity).parse(testValue, 0);
Assert.fail();
} catch (final PegNoMatchFoundException e) {
// System.out.println(e.getFullMessage());
Assert.assertEquals(testValue.indexOf("maxLengh") + "maxLengh".length() - 1, e.getIndex());
}
}
Aggregations