Skip to content

Commit 824352c

Browse files
committed
EnhancedErrorDialog: added null check for throwable argument.
1 parent ce75f2c commit 824352c

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/main/java/it/albertus/jface/EnhancedErrorDialog.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,27 @@ else if (IDialogConstants.HIDE_DETAILS_LABEL.equals(detailsButton.getText())) {
148148
public static MultiStatus createMultiStatus(final int severity, final Throwable throwable) {
149149
final Collection<IStatus> childStatuses = new ArrayList<IStatus>();
150150

151-
StringReader sr = null;
152-
BufferedReader br = null;
153-
try {
154-
sr = new StringReader(ExceptionUtils.getStackTrace(throwable));
155-
br = new BufferedReader(sr);
156-
String line;
157-
while ((line = br.readLine()) != null) {
158-
final IStatus status = new Status(severity, throwable.getClass().getName(), line.replace("\t", NESTING_INDENT));
159-
childStatuses.add(status);
151+
if (throwable != null) {
152+
StringReader sr = null;
153+
BufferedReader br = null;
154+
try {
155+
sr = new StringReader(ExceptionUtils.getStackTrace(throwable));
156+
br = new BufferedReader(sr);
157+
String line;
158+
while ((line = br.readLine()) != null) {
159+
final IStatus status = new Status(severity, throwable.getClass().getName(), line.replace("\t", NESTING_INDENT));
160+
childStatuses.add(status);
161+
}
162+
}
163+
catch (final IOException e) {
164+
log.log(Level.WARNING, "An error occurred while collecting statuses:", e);
165+
}
166+
finally {
167+
IOUtils.closeQuietly(br, sr);
160168
}
161-
}
162-
catch (final IOException e) {
163-
log.log(Level.WARNING, "An error occurred while collecting statuses:", e);
164-
}
165-
finally {
166-
IOUtils.closeQuietly(br, sr);
167169
}
168170

169-
return new MultiStatus(EnhancedErrorDialog.class.getPackage().getName(), severity, childStatuses.toArray(new IStatus[childStatuses.size()]), throwable.toString(), throwable);
171+
return new MultiStatus(EnhancedErrorDialog.class.getPackage().getName(), severity, childStatuses.toArray(new IStatus[childStatuses.size()]), String.valueOf(throwable), throwable);
170172
}
171173

172174
}

0 commit comments

Comments
 (0)