Revision 65e61086
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.application/META-INF/MANIFEST.MF | ||
---|---|---|
14 | 14 |
org.eclipse.equinox.app, |
15 | 15 |
org.eclipse.equinox.p2.repository.metadata, |
16 | 16 |
org.osgi.framework, |
17 |
org.osgi.service.packageadmin |
|
17 |
org.osgi.service.packageadmin, |
|
18 |
org.springframework.remoting |
|
18 | 19 |
Require-Bundle: org.eclipse.ui, |
19 | 20 |
org.eclipse.core.runtime, |
20 | 21 |
eu.etaxonomy.taxeditor.store, |
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java | ||
---|---|---|
8 | 8 |
import org.eclipse.ui.application.WorkbenchWindowAdvisor; |
9 | 9 |
import org.eclipse.ui.statushandlers.AbstractStatusHandler; |
10 | 10 |
import org.eclipse.ui.statushandlers.StatusAdapter; |
11 |
import org.springframework.remoting.RemoteAccessException; |
|
12 |
import org.springframework.remoting.RemoteConnectFailureException; |
|
11 | 13 |
|
12 | 14 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
13 | 15 |
|
... | ... | |
22 | 24 |
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { |
23 | 25 |
|
24 | 26 |
private CdmStatusHandler cdmStatusHandler; |
27 |
|
|
25 | 28 |
/* |
26 | 29 |
* (non-Javadoc) |
27 | 30 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer) |
... | ... | |
88 | 91 |
*/ |
89 | 92 |
class CdmStatusHandler extends AbstractStatusHandler { |
90 | 93 |
|
94 |
private Throwable previousT; |
|
91 | 95 |
/* (non-Javadoc) |
92 | 96 |
* @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter, int) |
93 | 97 |
*/ |
94 | 98 |
@Override |
95 | 99 |
public void handle(StatusAdapter statusAdapter, int style) |
96 | 100 |
{ |
101 |
|
|
97 | 102 |
if(statusAdapter.getStatus().matches(IStatus.ERROR)) { |
98 | 103 |
|
99 | 104 |
IStatus status = statusAdapter.getStatus(); |
100 | 105 |
Throwable t = statusAdapter.getStatus().getException(); |
106 |
// NOTE : the global status handling mechanism in the case of |
|
107 |
// runtime exceptions is called twice, once by the application |
|
108 |
// throwing the exception and then by the rcp logging mechanism |
|
109 |
// The check below is to make sure that the same exception is |
|
110 |
// not shown twice in succession. |
|
111 |
if(t != null && previousT == t) { |
|
112 |
return; |
|
113 |
} |
|
114 |
previousT = t; |
|
101 | 115 |
// NOTE : Currently we only allow RuntimeExceptions since |
102 | 116 |
// allowing all kinds of exceptions would also include |
103 | 117 |
// those in generated status objects coming from from logging triggers |
104 | 118 |
// leading to a recursive infinite loop of : |
105 | 119 |
// initial exception thrown -> status handling -> dialog opening + logging of status -> |
106 | 120 |
// status handling -> dialog opening + logging of status ... and so on |
107 |
if(t != null && t instanceof RuntimeException && ! "Widget is disposed".equals(t.getMessage())){ |
|
108 |
MessagingUtils.errorDialog("Unexpected error", |
|
109 |
null, |
|
110 |
MessagingUtils.UNEXPECTED_ERROR_MESSAGE, |
|
111 |
statusAdapter.getStatus().getPlugin(), |
|
112 |
t, |
|
113 |
true); |
|
114 |
} |
|
121 |
if(t != null && |
|
122 |
t instanceof RuntimeException && |
|
123 |
! "Widget is disposed".equals(t.getMessage()) && |
|
124 |
! handleKnownRuntimeException(t,statusAdapter.getStatus().getPlugin())) { |
|
125 |
|
|
126 |
MessagingUtils.errorDialog("Unexpected error", |
|
127 |
null, |
|
128 |
MessagingUtils.UNEXPECTED_ERROR_MESSAGE, |
|
129 |
statusAdapter.getStatus().getPlugin(), |
|
130 |
t, |
|
131 |
true); |
|
132 |
|
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
private boolean handleKnownRuntimeException(Throwable t, String pluginId) { |
|
138 |
if(t instanceof RemoteConnectFailureException || |
|
139 |
t.getCause() instanceof RemoteConnectFailureException) { |
|
140 |
MessagingUtils.errorDialog("Connection Failure", |
|
141 |
null, |
|
142 |
MessagingUtils.CONNECTION_FAILURE_MESSAGE + System.getProperty("line.separator"), |
|
143 |
pluginId, |
|
144 |
t, |
|
145 |
true, |
|
146 |
false); |
|
147 |
return true; |
|
148 |
} |
|
149 |
if(t instanceof RemoteAccessException || |
|
150 |
t.getCause() instanceof RemoteAccessException) { |
|
151 |
MessagingUtils.errorDialog("Remote Access Error", |
|
152 |
null, |
|
153 |
MessagingUtils.REMOTE_ACCESS_FAILURE_MESSAGE + System.getProperty("line.separator"), |
|
154 |
pluginId, |
|
155 |
t, |
|
156 |
true, |
|
157 |
false); |
|
158 |
return true; |
|
115 | 159 |
} |
160 |
return false; |
|
116 | 161 |
} |
117 | 162 |
} |
118 | 163 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/CdmErrorDialog.java | ||
---|---|---|
47 | 47 |
String dialogTitle, |
48 | 48 |
String message, |
49 | 49 |
IStatus status, |
50 |
String stackTrace) { |
|
50 |
String stackTrace, |
|
51 |
boolean showStatusMessage) { |
|
51 | 52 |
super(parentShell, |
52 | 53 |
dialogTitle, |
53 | 54 |
message, status, |
54 | 55 |
IStatus.OK| IStatus.INFO | IStatus.WARNING | IStatus.ERROR); |
55 | 56 |
this.stackTrace = stackTrace; |
56 |
|
|
57 |
|
|
57 |
String statusMessage = ""; |
|
58 |
if(showStatusMessage) { |
|
59 |
statusMessage = status.getMessage(); |
|
60 |
} |
|
61 |
this.message = message == null ? statusMessage : message + "\n " + statusMessage; |
|
58 | 62 |
} |
59 | 63 |
|
60 |
/** |
|
61 |
* @param parentShell |
|
62 |
* @param dialogTitle |
|
63 |
* @param message |
|
64 |
* @param status |
|
65 |
* @param stackTrace |
|
66 |
*/ |
|
67 |
public CdmErrorDialog(Shell parentShell, |
|
68 |
String dialogTitle, |
|
69 |
String message, |
|
70 |
IStatus status, |
|
71 |
String stackTrace, |
|
72 |
Object[] updatedObjects) { |
|
73 |
this(parentShell, dialogTitle, message, status, stackTrace); |
|
74 |
this.message = message == null ? status.getMessage() |
|
75 |
: message + "\n " + status.getMessage(); //$NON-NLS-1$ |
|
76 |
} |
|
77 | 64 |
|
78 | 65 |
/** |
79 | 66 |
* @param parentShell |
... | ... | |
85 | 72 |
String dialogTitle, |
86 | 73 |
String message, |
87 | 74 |
IStatus status) { |
88 |
this(parentShell, dialogTitle, message, status, ""); |
|
75 |
this(parentShell, dialogTitle, message, status, "", true);
|
|
89 | 76 |
} |
90 | 77 |
|
91 | 78 |
/* (non-Javadoc) |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java | ||
---|---|---|
31 | 31 |
public final static String UNEXPECTED_ERROR_MESSAGE = "This is an unexpected error."; |
32 | 32 |
public final static String CONTACT_MESSAGE = System.getProperty("line.separator") + "Please contact EDIT Support (EditSupport@bgbm.org) with the error trace below (click on the 'Details' button)."; |
33 | 33 |
public final static String DEFAULT_MESSAGE = "Error thrown but no associated message"; |
34 |
public final static String CONNECTION_FAILURE_MESSAGE = "The connection to the remote server has been broken"; |
|
35 |
public final static String REMOTE_ACCESS_FAILURE_MESSAGE = "Problem accessing remote server"; |
|
34 | 36 |
|
35 | 37 |
/** |
36 | 38 |
* Gets the Log4J logger for a given class |
... | ... | |
253 | 255 |
final Throwable t, |
254 | 256 |
final List<String> contextInfo, |
255 | 257 |
final String message, |
256 |
final MultiStatus status) { |
|
258 |
final MultiStatus status, |
|
259 |
final boolean showReason) { |
|
257 | 260 |
|
258 | 261 |
Display.getDefault().asyncExec(new Runnable() { |
259 | 262 |
|
260 | 263 |
@Override |
261 | 264 |
public void run() { |
262 | 265 |
String stackTraceWithContext = getStackTraceAndContextInfo(t, contextInfo); |
263 |
CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext); |
|
266 |
CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext, showReason);
|
|
264 | 267 |
ced.open(); |
265 | 268 |
Class<? extends Object> clazz = source != null ? source.getClass() : this.getClass(); |
266 | 269 |
|
... | ... | |
275 | 278 |
}); |
276 | 279 |
} |
277 | 280 |
|
281 |
public static void errorDialog(final String title, |
|
282 |
final Object source, |
|
283 |
final String message, |
|
284 |
final String pluginId, |
|
285 |
final Throwable t, |
|
286 |
boolean addContactMesg) { |
|
287 |
errorDialog(title, source, message, pluginId, t, addContactMesg, true); |
|
288 |
|
|
289 |
} |
|
278 | 290 |
/** |
279 | 291 |
* Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}. |
280 | 292 |
* |
... | ... | |
289 | 301 |
final String message, |
290 | 302 |
final String pluginId, |
291 | 303 |
final Throwable t, |
292 |
boolean addContactMesg) { |
|
304 |
boolean addContactMesg, |
|
305 |
boolean showReason) { |
|
293 | 306 |
|
294 | 307 |
Throwable throwable = t; |
295 | 308 |
StringBuffer sbStackTrace = new StringBuffer(); |
... | ... | |
356 | 369 |
throwable.toString(), |
357 | 370 |
throwable); |
358 | 371 |
|
359 |
errorDialog(title, source, throwable, contextInfo, finalMessage, ms); |
|
372 |
errorDialog(title, source, throwable, contextInfo, finalMessage, ms, showReason);
|
|
360 | 373 |
} |
361 | 374 |
|
362 | 375 |
/** |
Also available in: Unified diff
#5209 Beautify error messages related to connection / access to remote server