Search in sources :

Example 6 with GraqlQueryException

use of ai.grakn.exception.GraqlQueryException in project grakn by graknlabs.

the class RemoteGraknTxTest method whenAnErrorOccurs_AllFutureActionsThrow.

@Test
public void whenAnErrorOccurs_AllFutureActionsThrow() {
    Query<?> query = match(var("x")).get();
    TxRequest execQueryRequest = GrpcUtil.execQueryRequest(query);
    throwOn(execQueryRequest, ErrorType.GRAQL_QUERY_EXCEPTION, "well something went wrong");
    try (GraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.WRITE))) {
        try {
            tx.graql().match(var("x")).get().execute();
        } catch (GraqlQueryException e) {
        // Ignore
        }
        exception.expect(GraknTxOperationException.class);
        exception.expectMessage(GraknTxOperationException.transactionClosed(null, "The gRPC connection closed").getMessage());
        tx.admin().getMetaConcept();
    }
}
Also used : GraknTx(ai.grakn.GraknTx) TxRequest(ai.grakn.rpc.generated.GrpcGrakn.TxRequest) GraqlQueryException(ai.grakn.exception.GraqlQueryException) Test(org.junit.Test)

Aggregations

GraqlQueryException (ai.grakn.exception.GraqlQueryException)6 GraknTx (ai.grakn.GraknTx)3 ReasonerQuery (ai.grakn.graql.admin.ReasonerQuery)2 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)2 TxRequest (ai.grakn.rpc.generated.GrpcGrakn.TxRequest)2 Stream (java.util.stream.Stream)2 Test (org.junit.Test)2 ConceptId (ai.grakn.concept.ConceptId)1 Relationship (ai.grakn.concept.Relationship)1 RelationshipType (ai.grakn.concept.RelationshipType)1 Role (ai.grakn.concept.Role)1 SchemaConcept (ai.grakn.concept.SchemaConcept)1 Type (ai.grakn.concept.Type)1 Match (ai.grakn.graql.Match)1 Var (ai.grakn.graql.Var)1 Answer (ai.grakn.graql.admin.Answer)1 Atomic (ai.grakn.graql.admin.Atomic)1 Conjunction (ai.grakn.graql.admin.Conjunction)1 EquivalentFragmentSet (ai.grakn.graql.internal.gremlin.EquivalentFragmentSet)1 GraqlTraversal (ai.grakn.graql.internal.gremlin.GraqlTraversal)1