Skip to content

Instantly share code, notes, and snippets.

@udoprog
Last active October 18, 2016 13:29
Show Gist options
  • Select an option

  • Save udoprog/e6b2efcf7fb6da13cb7ffacb12edebcc to your computer and use it in GitHub Desktop.

Select an option

Save udoprog/e6b2efcf7fb6da13cb7ffacb12edebcc to your computer and use it in GitHub Desktop.
Case where non-final is OK
public class Main {
public static void main(String[] argv) throws Exception {
Exception e = null;
try {
doSomething();
} catch(final Exception inner) {
e = inner;
}
try {
doSometingElse();
} catch(final Exception inner) {
if (e != null) {
inner.addSuppressed(e);
}
e = inner;
}
if (e != null) {
throw e;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment