1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 00:38:52 -05:00

Distinct combined error messages for SuppressedThrowables

This commit is contained in:
Reinhard Pointner 2016-10-21 02:20:31 +08:00
parent c307cc8fc8
commit dcf3c4931c

View File

@ -15,7 +15,7 @@ public class SuppressedThrowables extends RuntimeException {
}
public SuppressedThrowables(String message, Throwable... causes) {
super(message(message, causes), causes.length > 0 ? causes[causes.length - 1] : null); // last exception as default cause
super(getMessage(message, causes), causes.length > 0 ? causes[causes.length - 1] : null); // last exception as default cause
this.causes = causes;
}
@ -23,20 +23,20 @@ public class SuppressedThrowables extends RuntimeException {
return causes.clone();
}
private static String message(String message, Throwable... causes) {
private static String getMessage(String message, Throwable... causes) {
if (causes.length == 0) {
return message;
}
if (message == null || message.isEmpty()) {
return message(causes);
return getMessage(causes);
}
return message + ": " + message(causes);
return message + ": " + getMessage(causes);
}
private static String message(Throwable... causes) {
return stream(causes).map(Throwable::getMessage).map(Objects::toString).collect(joining("; "));
private static String getMessage(Throwable... causes) {
return stream(causes).map(Throwable::getMessage).map(Objects::toString).distinct().collect(joining("; "));
}
}