Skip to content

Commit 39b3806

Browse files
committed
Initial GQL errors
1 parent 6c63a14 commit 39b3806

File tree

68 files changed

+978
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+978
-148
lines changed

driver/src/main/java/org/neo4j/driver/Values.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ public static Value value(Object value) {
213213
return value(Arrays.asList((Object[]) value));
214214
}
215215

216-
throw new ClientException("Unable to convert " + value.getClass().getName() + " to Neo4j Value.");
216+
throw new ClientException(
217+
"22000",
218+
"data exception",
219+
"Unable to convert " + value.getClass().getName() + " to Neo4j Value.");
217220
}
218221

219222
/**
@@ -588,10 +591,13 @@ public static Value point(int srid, double x, double y, double z) {
588591
*/
589592
public static Value parameters(Object... keysAndValues) {
590593
if (keysAndValues.length % 2 != 0) {
591-
throw new ClientException("Parameters function requires an even number " + "of arguments, "
592-
+ "alternating key and value. Arguments were: "
593-
+ Arrays.toString(keysAndValues)
594-
+ ".");
594+
throw new ClientException(
595+
"22000",
596+
"data exception",
597+
"Parameters function requires an even number " + "of arguments, "
598+
+ "alternating key and value. Arguments were: "
599+
+ Arrays.toString(keysAndValues)
600+
+ ".");
595601
}
596602
HashMap<String, Value> map = newHashMapWithSize(keysAndValues.length / 2);
597603
for (var i = 0; i < keysAndValues.length; i += 2) {

driver/src/main/java/org/neo4j/driver/exceptions/AuthTokenManagerExecutionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public class AuthTokenManagerExecutionException extends ClientException {
4242
* @param cause the cause
4343
*/
4444
public AuthTokenManagerExecutionException(String message, Throwable cause) {
45-
super(message, cause);
45+
super("22000", "data exception", message, cause);
4646
}
4747
}

driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.neo4j.driver.exceptions;
1818

1919
import java.io.Serial;
20+
import java.util.Map;
21+
import org.neo4j.driver.Value;
2022

2123
/**
2224
* Failed to authenticate the driver to the server due to bad credentials provided.
@@ -37,4 +39,23 @@ public class AuthenticationException extends SecurityException {
3739
public AuthenticationException(String code, String message) {
3840
super(code, message);
3941
}
42+
43+
/**
44+
* TODO
45+
* @param gqlStatus TODO
46+
* @param statusExplanation TODO
47+
* @param code TODO
48+
* @param message TODO
49+
* @param diagnosticRecord TODO
50+
* @param cause TODO
51+
*/
52+
public AuthenticationException(
53+
String gqlStatus,
54+
String statusExplanation,
55+
String code,
56+
String message,
57+
Map<String, Value> diagnosticRecord,
58+
Throwable cause) {
59+
super(gqlStatus, statusExplanation, code, message, diagnosticRecord, cause);
60+
}
4061
}

driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.neo4j.driver.exceptions;
1818

1919
import java.io.Serial;
20+
import java.util.Map;
21+
import org.neo4j.driver.Value;
2022

2123
/**
2224
* The authorization info maintained on the server has expired. The client should reconnect.
@@ -41,4 +43,23 @@ public class AuthorizationExpiredException extends SecurityException implements
4143
public AuthorizationExpiredException(String code, String message) {
4244
super(code, message);
4345
}
46+
47+
/**
48+
* TODO
49+
* @param gqlStatus TODO
50+
* @param statusExplanation TODO
51+
* @param code TODO
52+
* @param message TODO
53+
* @param diagnosticRecord TODO
54+
* @param cause TODO
55+
*/
56+
public AuthorizationExpiredException(
57+
String gqlStatus,
58+
String statusExplanation,
59+
String code,
60+
String message,
61+
Map<String, Value> diagnosticRecord,
62+
Throwable cause) {
63+
super(gqlStatus, statusExplanation, code, message, diagnosticRecord, cause);
64+
}
4465
}

driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.neo4j.driver.exceptions;
1818

1919
import java.io.Serial;
20+
import java.util.Map;
21+
import org.neo4j.driver.Value;
2022

2123
/**
2224
* A <em>ClientException</em> indicates that the client has carried out an operation incorrectly.
@@ -31,6 +33,7 @@ public class ClientException extends Neo4jException {
3133
* Creates a new instance.
3234
* @param message the message
3335
*/
36+
// for testing only
3437
public ClientException(String message) {
3538
super(message);
3639
}
@@ -40,6 +43,7 @@ public ClientException(String message) {
4043
* @param message the message
4144
* @param cause the cause
4245
*/
46+
// for testing only
4347
public ClientException(String message, Throwable cause) {
4448
super(message, cause);
4549
}
@@ -52,4 +56,46 @@ public ClientException(String message, Throwable cause) {
5256
public ClientException(String code, String message) {
5357
super(code, message);
5458
}
59+
60+
/**
61+
* TODO
62+
* @param gqlStatus TODO
63+
* @param statusExplanation TODO
64+
* @param message TODO
65+
* @since 5.23.0
66+
*/
67+
public ClientException(String gqlStatus, String statusExplanation, String message) {
68+
this(gqlStatus, statusExplanation, message, null);
69+
}
70+
71+
/**
72+
* TODO
73+
* @param gqlStatus TODO
74+
* @param statusExplanation TODO
75+
* @param message TODO
76+
* @param cause TODO
77+
* @since 5.23.0
78+
*/
79+
public ClientException(String gqlStatus, String statusExplanation, String message, Throwable cause) {
80+
super(gqlStatus, statusExplanation, message, cause);
81+
}
82+
83+
/**
84+
* TODO
85+
* @param gqlStatus TODO
86+
* @param statusExplanation TODO
87+
* @param code TODO
88+
* @param message TODO
89+
* @param diagnosticRecord TODO
90+
* @param cause TODO
91+
*/
92+
public ClientException(
93+
String gqlStatus,
94+
String statusExplanation,
95+
String code,
96+
String message,
97+
Map<String, Value> diagnosticRecord,
98+
Throwable cause) {
99+
super(gqlStatus, statusExplanation, code, message, diagnosticRecord, cause);
100+
}
55101
}

driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.neo4j.driver.exceptions;
1818

1919
import java.io.Serial;
20+
import java.util.Map;
21+
import org.neo4j.driver.Value;
2022

2123
/**
2224
* A <em>DatabaseException</em> indicates that there is a problem within the underlying database.
@@ -35,4 +37,23 @@ public class DatabaseException extends Neo4jException {
3537
public DatabaseException(String code, String message) {
3638
super(code, message);
3739
}
40+
41+
/**
42+
* TODO
43+
* @param gqlStatus TODO
44+
* @param statusExplanation TODO
45+
* @param code TODO
46+
* @param message TODO
47+
* @param diagnosticRecord TODO
48+
* @param cause TODO
49+
*/
50+
public DatabaseException(
51+
String gqlStatus,
52+
String statusExplanation,
53+
String code,
54+
String message,
55+
Map<String, Value> diagnosticRecord,
56+
Throwable cause) {
57+
super(gqlStatus, statusExplanation, code, message, diagnosticRecord, cause);
58+
}
3859
}

driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public class DiscoveryException extends Neo4jException {
3636
* @param cause the cause
3737
*/
3838
public DiscoveryException(String message, Throwable cause) {
39-
super(message, cause);
39+
super("08000", "connection exception", message, cause);
4040
}
4141
}

driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.neo4j.driver.exceptions;
1818

1919
import java.io.Serial;
20+
import java.util.Map;
21+
import org.neo4j.driver.Value;
2022

2123
/**
2224
* This error indicate a fatal problem to obtain routing tables such as the routing table for a specified database does not exist.
@@ -32,7 +34,7 @@ public class FatalDiscoveryException extends ClientException {
3234
* @param message the message
3335
*/
3436
public FatalDiscoveryException(String message) {
35-
super(message);
37+
super("08000", "connection exception", message);
3638
}
3739

3840
/**
@@ -43,4 +45,23 @@ public FatalDiscoveryException(String message) {
4345
public FatalDiscoveryException(String code, String message) {
4446
super(code, message);
4547
}
48+
49+
/**
50+
* TODO
51+
* @param gqlStatus TODO
52+
* @param statusExplanation TODO
53+
* @param code TODO
54+
* @param message TODO
55+
* @param diagnosticRecord TODO
56+
* @param cause TODO
57+
*/
58+
public FatalDiscoveryException(
59+
String gqlStatus,
60+
String statusExplanation,
61+
String code,
62+
String message,
63+
Map<String, Value> diagnosticRecord,
64+
Throwable cause) {
65+
super(gqlStatus, statusExplanation, code, message, diagnosticRecord, cause);
66+
}
4667
}

0 commit comments

Comments
 (0)