Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch and send Cypher syntax errors to client as 400 response (#289). #4

Open
wants to merge 1 commit into
base: cypher-execute-fix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -63,6 +64,8 @@
@Produces({MediaType.TEXT_PLAIN})
public class CypherUtilService extends BaseResource {

private static final Logger logger = Logger.getLogger(CypherUtilService.class.getName());

final private CypherUtil cypherUtil;
final private GraphDatabaseService graphDb;
final private CurieUtil curieUtil;
Expand Down Expand Up @@ -131,6 +134,10 @@ public Response execute(
} else {
return Response.ok(cypherUtil.execute(replacedStartCurie).resultAsString()).cacheControl(null).build();
}
} catch (QueryExecutionException e) {
String errorMsg = "QueryExecutionException: " + e.getMessage();
logger.warning(errorMsg);
return Response.status(400).entity(errorMsg).build();
} catch (TransactionTerminatedException e) {
return Response.ok("The query execution exceeds dbms.transaction.timeout configuration. " +
"Consider using the neo4j shell instead of this service.").build();
Expand Down