Skip to content

Instantly share code, notes, and snippets.

@korzha
Created June 5, 2016 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korzha/0313dc05be37d77a40901f7172590390 to your computer and use it in GitHub Desktop.
Save korzha/0313dc05be37d77a40901f7172590390 to your computer and use it in GitHub Desktop.
ArrayList<Throwable> throwables = new ArrayList<>();
onClose.forEach((runnable) -> {
try {
runnable.run();
} catch (Throwable e) {
throwables.add(e);
}
});
if (!throwables.isEmpty()) {
Throwable e = throwables.get(0);
for (int i = 1; i < throwables.size(); i++) {
Throwable suppressed = throwables.get(i);
if (suppressed != e) {
e.addSuppressed(suppressed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment