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