Skip to content

Commit 8b2769d

Browse files
committed
More review changes.
1 parent 5d2dc69 commit 8b2769d

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/ui/console/log/LogPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private String printException(Exception exception) {
164164
errorMessage = exception.toString();
165165
}
166166
error(errorMessage);
167-
String newLine = "\n";
167+
String newLine = System.lineSeparator();
168168
String details = exception.getMessage() + newLine + getCause(exception) + newLine + getStackTrace(exception);
169169
log.printHyperlink(" " + SHOW_DETAILS, p -> showPopup("Error details", details, exception));
170170
newLine();

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/util/ExceptionErrorMessages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.neueda.jetbrains.plugin.graphdb.jetbrains.util;
22

33
public enum ExceptionErrorMessages {
4-
SYNTAX_EXCEPTION("Please note that Cypher query is translated to Gremlin and may fail" +
4+
ERROR_OCCURRED("Error occurred."),
5+
SYNTAX_WARNING("Please note that Cypher query is translated to Gremlin and may fail " +
56
"because of translation or database specifics. Make sure that flavor is properly configured in database connection configuration."),
67
SERIALIZER_EXCEPTION("Wrong serializer selected. Please check connection configuration."),
78
RESPONSE_EXCEPTION("Database connection failed. Please check database configuration and retry to connect."),

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/util/ExceptionWrapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public static String getStackTrace(final Throwable throwable) {
5151

5252
public static String wrapExceptionInMeaningMessage(Exception exception) {
5353
String exceptionMessage = exception.getMessage();
54+
if (exceptionMessage.isEmpty()) {
55+
return ExceptionErrorMessages.ERROR_OCCURRED.getDescription();
56+
}
5457
if (exceptionMessage.contains("SerializationException")) {
5558
return ExceptionErrorMessages.SERIALIZER_EXCEPTION.getDescription();
5659
}
@@ -61,7 +64,7 @@ public static String wrapExceptionInMeaningMessage(Exception exception) {
6164
return ExceptionErrorMessages.CONNECTION_EXCEPTION.getDescription();
6265
}
6366
if (exceptionMessage.contains("SyntaxException")) {
64-
return ExceptionErrorMessages.SYNTAX_EXCEPTION.getDescription();
67+
return ExceptionErrorMessages.SYNTAX_WARNING.getDescription();
6568
}
6669
if (exceptionMessage.length() > SHORT_STRING_LENGTH) {
6770
return ellipseString(exceptionMessage, SHORT_STRING_LENGTH);

ui/jetbrains/src/test/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/ui/helpers/ExceptionWrapperTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.helpers;
22

3+
import com.neueda.jetbrains.plugin.graphdb.jetbrains.util.ExceptionErrorMessages;
34
import com.neueda.jetbrains.plugin.graphdb.jetbrains.util.ExceptionWrapper;
5+
import org.junit.Rule;
46
import org.junit.Test;
7+
import org.junit.rules.ExpectedException;
8+
import org.opencypher.v9_0.util.SyntaxException;
59

10+
import static org.hamcrest.core.Is.*;
611
import static org.junit.Assert.*;
712

813
public class ExceptionWrapperTest {
@@ -14,4 +19,26 @@ public void shouldEllipseString() throws Exception {
1419
String truncatedString = ExceptionWrapper.ellipseString(longString, ExceptionWrapper.SHORT_STRING_LENGTH);
1520
assertEquals(shortString, truncatedString);
1621
}
22+
23+
@Rule
24+
public ExpectedException thrown = ExpectedException.none();
25+
26+
@Test(expected = SyntaxException.class)
27+
public void shouldWrapExceptionInMeaningMessage() throws Exception {
28+
try {
29+
TestThing testThing = new TestThing();
30+
testThing.chuck();
31+
fail("should have thrown");
32+
} catch (SyntaxException e) {
33+
assertThat(ExceptionWrapper.wrapExceptionInMeaningMessage(e), is(ExceptionErrorMessages.SYNTAX_WARNING));
34+
}
35+
36+
}
37+
38+
private class TestThing {
39+
public void chuck() {
40+
String exceptionMessage = "org.opencypher.v9_0.util.SyntaxException: Invalid input 'R':...";
41+
throw new SyntaxException(exceptionMessage);
42+
}
43+
}
1744
}

0 commit comments

Comments
 (0)