use of mb.nabl2.relations.RelationException in project nabl by metaborg.
the class RelationComponent method solve.
// ------------------------------------------------------------------------------------------------------//
public Optional<SolveResult> solve(CBuildRelation c) {
final ITerm left = unifier().findRecursive(c.getLeft());
final ITerm right = unifier().findRecursive(c.getRight());
if (!(left.isGround() && right.isGround())) {
return Optional.empty();
}
return c.getRelation().match(IRelationName.Cases.of(// @formatter:off
name -> {
try {
relation(name).add(left, right);
} catch (RelationException e) {
final IMessageInfo message = c.getMessageInfo().withDefaultContent(MessageContent.of(e.getMessage()));
return Optional.of(SolveResult.messages(message));
}
return Optional.of(SolveResult.empty());
}, extName -> {
throw new IllegalArgumentException("Cannot add entries to external relations.");
}));
}
Aggregations