Skip to content

Commit c61a5eb

Browse files
author
DvirDukhan
committed
refactor - rename from error to exception. added JDoc
1 parent c14484e commit c61a5eb

File tree

7 files changed

+57
-55
lines changed

7 files changed

+57
-55
lines changed

src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphCompileTimeError.java

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.redislabs.redisgraph.exceptions;
2+
3+
import redis.clients.jedis.exceptions.JedisDataException;
4+
5+
/**
6+
* RedisGraph query syntax evaluation exception. An instance of JRedisGraphRunTimeException is thrown when RedisGraph
7+
* encounters an error during query syntax evaluation.
8+
*/
9+
public class JRedisGraphCompileTimeException extends JedisDataException {
10+
public JRedisGraphCompileTimeException(String message) {
11+
super(message);
12+
}
13+
14+
public JRedisGraphCompileTimeException(Throwable cause) {
15+
super(cause);
16+
}
17+
18+
public JRedisGraphCompileTimeException(String message, Throwable cause) {
19+
super(message, cause);
20+
}
21+
}

src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphRunTimeError.java

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.redislabs.redisgraph.exceptions;
2+
3+
import redis.clients.jedis.exceptions.JedisDataException;
4+
5+
/**
6+
* RedisGraph runtime exception. An instance of JRedisGraphRunTimeException is thrown when RedisGraph
7+
* encounters a runtime error during query execution.
8+
*/
9+
public class JRedisGraphRunTimeException extends JedisDataException {
10+
public JRedisGraphRunTimeException(String message) {
11+
super(message);
12+
}
13+
14+
public JRedisGraphRunTimeException(Throwable cause) {
15+
super(cause);
16+
}
17+
18+
public JRedisGraphRunTimeException(String message, Throwable cause) {
19+
super(message, cause);
20+
}
21+
}

src/main/java/com/redislabs/redisgraph/impl/api/ContextedRedisGraph.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.redislabs.redisgraph.RedisGraphContext;
44
import com.redislabs.redisgraph.ResultSet;
5-
import com.redislabs.redisgraph.exceptions.JRedisGraphCompileTimeError;
6-
import com.redislabs.redisgraph.exceptions.JRedisGraphRunTimeError;
5+
import com.redislabs.redisgraph.exceptions.JRedisGraphCompileTimeException;
6+
import com.redislabs.redisgraph.exceptions.JRedisGraphRunTimeException;
77
import com.redislabs.redisgraph.impl.Utils;
88
import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches;
99
import com.redislabs.redisgraph.impl.resultset.ResultSetImpl;
@@ -52,11 +52,11 @@ protected ResultSet sendQuery(String graphId, String preparedQuery) {
5252
List<Object> rawResponse = (List<Object>) conn.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING);
5353
return new ResultSetImpl(rawResponse, this, caches.getGraphCache(graphId));
5454
}
55-
catch (JRedisGraphRunTimeError rt) {
55+
catch (JRedisGraphRunTimeException rt) {
5656
throw rt;
5757
}
5858
catch (JedisDataException j) {
59-
throw new JRedisGraphCompileTimeError(j);
59+
throw new JRedisGraphCompileTimeException(j);
6060
}
6161
}
6262

src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.redislabs.redisgraph.RedisGraph;
66
import com.redislabs.redisgraph.ResultSet;
77
import com.redislabs.redisgraph.Statistics;
8-
import com.redislabs.redisgraph.exceptions.JRedisGraphRunTimeError;
8+
import com.redislabs.redisgraph.exceptions.JRedisGraphRunTimeException;
99
import com.redislabs.redisgraph.graph_entities.Edge;
1010
import com.redislabs.redisgraph.graph_entities.GraphEntity;
1111
import com.redislabs.redisgraph.graph_entities.Node;
@@ -41,7 +41,7 @@ public ResultSetImpl(List<Object> rawResponse, RedisGraph redisGraph, GraphCache
4141
// If a run-time error occured, the last member of the rawResponse will be a JedisDataException.
4242
if (rawResponse.get(rawResponse.size()-1) instanceof JedisDataException) {
4343

44-
throw new JRedisGraphRunTimeError((Throwable) rawResponse.get(rawResponse.size() - 1));
44+
throw new JRedisGraphRunTimeException((Throwable) rawResponse.get(rawResponse.size() - 1));
4545
}
4646

4747
if (rawResponse.size() != 3) {

src/test/java/com/redislabs/redisgraph/exceptions/JRedisGraphErrorTest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void deleteGraph() {
3232

3333
@Test
3434
public void testSyntaxErrorReporting() {
35-
exceptionRule.expect(JRedisGraphCompileTimeError.class);
35+
exceptionRule.expect(JRedisGraphCompileTimeException.class);
3636
exceptionRule.expectMessage("Type mismatch: expected String but was Integer");
3737

3838
// Issue a query that causes a compile-time error
@@ -42,7 +42,7 @@ public void testSyntaxErrorReporting() {
4242

4343
@Test
4444
public void testRuntimeErrorReporting() {
45-
exceptionRule.expect(JRedisGraphRunTimeError.class);
45+
exceptionRule.expect(JRedisGraphRunTimeException.class);
4646
exceptionRule.expectMessage("Type mismatch: expected String but was Integer");
4747

4848
// Issue a query that causes a run-time error
@@ -57,7 +57,7 @@ public void testExceptionFlow() {
5757
api.query("social", "RETURN toUpper(5)");
5858
}
5959
catch (Exception e) {
60-
Assert.assertEquals(JRedisGraphCompileTimeError.class, e.getClass());
60+
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass());
6161
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer"));
6262
}
6363

@@ -68,7 +68,7 @@ public void testExceptionFlow() {
6868
api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)");
6969
}
7070
catch (Exception e) {
71-
Assert.assertEquals(JRedisGraphRunTimeError.class, e.getClass());
71+
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass());
7272
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer"));
7373
}
7474

@@ -77,7 +77,7 @@ public void testExceptionFlow() {
7777

7878
@Test
7979
public void testContextSyntaxErrorReporting() {
80-
exceptionRule.expect(JRedisGraphCompileTimeError.class);
80+
exceptionRule.expect(JRedisGraphCompileTimeException.class);
8181
exceptionRule.expectMessage("Type mismatch: expected String but was Integer");
8282
RedisGraphContext c = api.getContext();
8383

@@ -88,7 +88,7 @@ public void testContextSyntaxErrorReporting() {
8888

8989
@Test
9090
public void testContextRuntimeErrorReporting() {
91-
exceptionRule.expect(JRedisGraphRunTimeError.class);
91+
exceptionRule.expect(JRedisGraphRunTimeException.class);
9292
exceptionRule.expectMessage("Type mismatch: expected String but was Integer");
9393

9494
RedisGraphContext c = api.getContext();
@@ -97,8 +97,6 @@ public void testContextRuntimeErrorReporting() {
9797
}
9898

9999

100-
101-
102100
@Test
103101
public void testContextExceptionFlow() {
104102

@@ -108,7 +106,7 @@ public void testContextExceptionFlow() {
108106
c.query("social", "RETURN toUpper(5)");
109107
}
110108
catch (Exception e) {
111-
Assert.assertEquals(JRedisGraphCompileTimeError.class, e.getClass());
109+
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass());
112110
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer"));
113111
}
114112

@@ -119,11 +117,9 @@ public void testContextExceptionFlow() {
119117
c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)");
120118
}
121119
catch (Exception e) {
122-
Assert.assertEquals(JRedisGraphRunTimeError.class, e.getClass());
120+
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass());
123121
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer"));
124122
}
125123

126124
}
127-
128-
129-
}
125+
}

0 commit comments

Comments
 (0)