18
18
import org .jetbrains .annotations .Nullable ;
19
19
20
20
import java .awt .*;
21
+ import java .util .HashMap ;
21
22
import java .util .Map ;
22
23
23
24
import static com .neueda .jetbrains .plugin .graphdb .jetbrains .ui .console .event .QueryParametersRetrievalErrorEvent .PARAMS_ERROR_COMMON_MSG ;
24
- import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .getCause ;
25
- import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .truncateString ;
25
+ import static com .neueda .jetbrains .plugin .graphdb .jetbrains .ui .console .log .ShowExceptionDetailsFilter .SHOW_DETAILS ;
26
26
import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .wrapExceptionInMeaningMessage ;
27
27
28
28
public class LogPanel implements Disposable {
29
-
30
29
private ConsoleView log ;
30
+ private Map <String , String > exceptions = new HashMap <>();
31
+ private Map <String , String > causes = new HashMap <>();
31
32
32
33
public void initialize (GraphConsoleView graphConsoleView , Project project ) {
33
34
MessageBus messageBus = project .getMessageBus ();
@@ -36,6 +37,7 @@ public void initialize(GraphConsoleView graphConsoleView, Project project) {
36
37
.createBuilder (project )
37
38
.getConsole ();
38
39
log .addMessageFilter (new GoToTabFilter (log ));
40
+ log .addMessageFilter (new ShowExceptionDetailsFilter (log , exceptions ));
39
41
40
42
Disposer .register (graphConsoleView , log );
41
43
graphConsoleView .getLogTab ().add (log .getComponent (), BorderLayout .CENTER );
@@ -110,8 +112,10 @@ public void metadataRefreshSucceed(DataSourceApi nodeDataSource, DataSourceMetad
110
112
111
113
@ Override
112
114
public void metadataRefreshFailed (DataSourceApi nodeDataSource , Exception exception ) {
113
- error (String .format ("DataSource[%s] - metadata refresh failed. Reason: " , nodeDataSource .getName ()));
114
- printException (exception );
115
+ String prefix = String .format ("DataSource[%s] - metadata refresh failed. Reason: " , nodeDataSource .getName ());
116
+ error (prefix );
117
+ String errorMessage = prefix + printException (exception ) + "\n " ;
118
+ exceptions .put (errorMessage , exception .getMessage ());
115
119
newLine ();
116
120
}
117
121
});
@@ -123,19 +127,19 @@ public void metadataRefreshFailed(DataSourceApi nodeDataSource, Exception except
123
127
});
124
128
}
125
129
126
- public void userInput (String message ) {
130
+ private void userInput (String message ) {
127
131
log .print (message , ConsoleViewContentType .USER_INPUT );
128
132
}
129
133
130
- public void printParametersMap (Map <String , Object > parameters ) {
134
+ private void printParametersMap (Map <String , Object > parameters ) {
131
135
for (Map .Entry <String , Object > entry : parameters .entrySet ()) {
132
136
String message = String .format ("%s: %s" , entry .getKey (), entry .getValue ());
133
137
log .print (message , ConsoleViewContentType .USER_INPUT );
134
138
newLine ();
135
139
}
136
140
}
137
141
138
- public void info (String message ) {
142
+ private void info (String message ) {
139
143
log .print (message , ConsoleViewContentType .NORMAL_OUTPUT );
140
144
}
141
145
@@ -145,20 +149,19 @@ public void error(@Nullable String message) {
145
149
}
146
150
}
147
151
148
- public void printException (Exception exception ) {
152
+ private String printException (Exception exception ) {
153
+ String errorMessage ;
149
154
if (exception .getMessage () != null ) {
150
- error ( wrapExceptionInMeaningMessage (exception )) ;
155
+ errorMessage = wrapExceptionInMeaningMessage (exception ) + " " + SHOW_DETAILS ;
151
156
} else {
152
- error ( exception .toString ()) ;
157
+ errorMessage = exception .toString () + " " + SHOW_DETAILS ;
153
158
}
159
+ error (errorMessage );
154
160
newLine ();
155
-
156
- String cause = getCause (exception );
157
- error (truncateString (cause , 100 ));
161
+ return errorMessage ;
158
162
}
159
163
160
-
161
- public void newLine () {
164
+ private void newLine () {
162
165
log .print ("\n " , ConsoleViewContentType .NORMAL_OUTPUT );
163
166
}
164
167
0 commit comments