Has anybody managed to show a detail error message in the JFace ErrorDialog using newline (\n, \r) character?
I’m trying to display the StackTrace as a detail message, but it is only shown in one line
StringBuffer sbStackTrace = new StringBuffer();
for (StackTraceElement ste : throwable.getStackTrace()) {
sbStackTrace.append(ste.toString()).append('\n');
}
final IStatus status = new Status(IStatus.ERROR, pluginId, statusMsg, new Throwable(sbStackTrace.toString(), throwable));
ErrorDialog dialog = new ErrorDialog(shell, "Error", customMessage, status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR)
On open the ErrorDialog shows eveything I want, except that the detail message is not properly formatted.
Any ideas?
Looking at the
ErrorDialog.populateList(List, IStatus, int, boolean)method in the source for ErrorDialog.java, it looks like the dialog only includes oneIStatusper line, but if thatIStatushas children, it will include them on subsequent lines. So you’ll need to either build aMultiStatusobject or create your own implementation ofIStatus.