Search in sources :

Example 1 with Neo4jException

use of org.neo4j.exceptions.Neo4jException in project neo4j by neo4j.

the class TestFabricTransaction method execute.

@Override
public Result execute(String query, Map<String, Object> parameters) throws QueryExecutionException {
    var ctx = new TestFabricTransactionalContext(kernelInternalTransaction);
    var params = ValueUtils.asParameterMapValue(parameters);
    var result = new ResultSubscriber(ctx, ctx.valueMapper());
    try {
        BoltQueryExecution boltQueryExecution = fabricTransaction.executeQuery(query, params, false, result);
        result.init(boltQueryExecution.getQueryExecution());
    } catch (FabricException e) {
        if (e.getCause() instanceof RuntimeException) {
            throw (RuntimeException) e.getCause();
        } else {
            throw new QueryExecutionException(e.getMessage(), e, e.status().code().serialize());
        }
    } catch (QueryExecutionKernelException | Neo4jException e) {
        throw new QueryExecutionException(e.getMessage(), e, e.status().code().serialize());
    }
    return result;
}
Also used : BoltQueryExecution(org.neo4j.bolt.dbapi.BoltQueryExecution) QueryExecutionException(org.neo4j.graphdb.QueryExecutionException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) ResultSubscriber(org.neo4j.cypher.internal.javacompat.ResultSubscriber) FabricException(org.neo4j.fabric.executor.FabricException) Neo4jException(org.neo4j.exceptions.Neo4jException)

Example 2 with Neo4jException

use of org.neo4j.exceptions.Neo4jException in project neo4j by neo4j.

the class Invocation method executeStatements.

private void executeStatements() {
    try {
        while (outputError == null) {
            memoryPool.reserveHeap(Statement.SHALLOW_SIZE);
            try {
                Statement statement = readStatement();
                if (statement == null) {
                    return;
                }
                executeStatement(statement);
            } finally {
                memoryPool.releaseHeap(Statement.SHALLOW_SIZE);
            }
        }
    } catch (InputFormatException e) {
        handleNeo4jError(Status.Request.InvalidFormat, e);
    } catch (KernelException | Neo4jException | AuthorizationViolationException | WriteOperationsNotAllowedException e) {
        handleNeo4jError(e.status(), e);
    } catch (DeadlockDetectedException e) {
        handleNeo4jError(Status.Transaction.DeadlockDetected, e);
    } catch (Exception e) {
        Throwable cause = e.getCause();
        if (cause instanceof Status.HasStatus) {
            handleNeo4jError(((Status.HasStatus) cause).status(), cause);
        } else {
            handleNeo4jError(Status.Statement.ExecutionFailed, e);
        }
    }
}
Also used : Status(org.neo4j.kernel.api.exceptions.Status) Statement(org.neo4j.server.http.cypher.format.api.Statement) DeadlockDetectedException(org.neo4j.kernel.DeadlockDetectedException) Neo4jException(org.neo4j.exceptions.Neo4jException) InputFormatException(org.neo4j.server.http.cypher.format.api.InputFormatException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) Neo4jException(org.neo4j.exceptions.Neo4jException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) KernelException(org.neo4j.exceptions.KernelException) InputFormatException(org.neo4j.server.http.cypher.format.api.InputFormatException) ConnectionException(org.neo4j.server.http.cypher.format.api.ConnectionException) AuthorizationViolationException(org.neo4j.graphdb.security.AuthorizationViolationException) InvalidSemanticsException(org.neo4j.exceptions.InvalidSemanticsException) DeadlockDetectedException(org.neo4j.kernel.DeadlockDetectedException) OutputFormatException(org.neo4j.server.http.cypher.format.api.OutputFormatException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) KernelException(org.neo4j.exceptions.KernelException) AuthorizationViolationException(org.neo4j.graphdb.security.AuthorizationViolationException)

Aggregations

Neo4jException (org.neo4j.exceptions.Neo4jException)2 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)2 BoltQueryExecution (org.neo4j.bolt.dbapi.BoltQueryExecution)1 ResultSubscriber (org.neo4j.cypher.internal.javacompat.ResultSubscriber)1 InvalidSemanticsException (org.neo4j.exceptions.InvalidSemanticsException)1 KernelException (org.neo4j.exceptions.KernelException)1 FabricException (org.neo4j.fabric.executor.FabricException)1 QueryExecutionException (org.neo4j.graphdb.QueryExecutionException)1 WriteOperationsNotAllowedException (org.neo4j.graphdb.WriteOperationsNotAllowedException)1 AuthorizationViolationException (org.neo4j.graphdb.security.AuthorizationViolationException)1 DeadlockDetectedException (org.neo4j.kernel.DeadlockDetectedException)1 Status (org.neo4j.kernel.api.exceptions.Status)1 ConnectionException (org.neo4j.server.http.cypher.format.api.ConnectionException)1 InputFormatException (org.neo4j.server.http.cypher.format.api.InputFormatException)1 OutputFormatException (org.neo4j.server.http.cypher.format.api.OutputFormatException)1 Statement (org.neo4j.server.http.cypher.format.api.Statement)1