Skip to content
Snippets Groups Projects
Commit 9a6891da authored by Alexander Diewald's avatar Alexander Diewald
Browse files

- Improve the error reporting from the DSE: Show the thrown Exception in the...

- Improve the error reporting from the DSE: Show the thrown Exception in the Dialog for easier collection of user feedback.
parent 91584fb3
No related branches found
No related tags found
No related merge requests found
......@@ -1006,50 +1006,6 @@ public class ExplorationAlgUtils {
return classMap.get(key);
}
/**
* Creates an {@link IStatus} element that aggregates stack trace messages is a
* {@link MultiStatus} object, if possible.
*
* @param e
* Exception to be show.
* @param launcherPluginID
* Corresponding ID of the caller's plugin.
* @param title
* Title string to be shown.
* @return {@link MultiStatus}, if the given exception is non-{@code null}, otherwise a
* {@link Status} object.
*/
public static IStatus createExceptionStatus(Exception e, String launcherPluginID, String title) {
IStatus status =
new Status(IStatus.ERROR, launcherPluginID, "Error executing " + title + ".", e);
status = tryCreateMultiStatusException(status);
if(ExplorationUtils.isDebugVerboseEnabled()) {
e.printStackTrace();
}
return status;
}
/**
* Aggregates possibly nested stack traces of an {@link IStatus} element and returns a
* MultiStatus object if exceptions are found. Otherwise the given {@link IStatus} is returned.
* Inspired from
* http://www.vogella.com/tutorials/EclipseDialogs/article.html#dialogs_jface_errordialog.
*/
static IStatus tryCreateMultiStatusException(IStatus status) {
Throwable t = status.getException();
if(t != null) {
StackTraceElement[] stackTraces = status.getException().getStackTrace();
Stream<Status> childStatuses =
Arrays.stream(stackTraces).map(
tr -> new Status(IStatus.ERROR, status.getPlugin(), tr.toString()));
return new MultiStatus(status.getPlugin(), status.getSeverity(),
childStatuses.toArray(size -> new Status[size]), status.getMessage(), t);
}
return status;
}
/**
* Takes a checked Exception and allows its usage in a RuntimeException based environment.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment