Skip to content

Instantly share code, notes, and snippets.

@danielkec
Created January 9, 2020 09:24
Show Gist options
  • Save danielkec/e6c6a317b41bb54a29455117d41d44a3 to your computer and use it in GitHub Desktop.
Save danielkec/e6c6a317b41bb54a29455117d41d44a3 to your computer and use it in GitHub Desktop.
throwUncheckedException
public class ExceptionUtils {
public static void throwUncheckedException(Throwable t) {
ExceptionUtils.<RuntimeException>throwWithTypeErasure(t);
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> void throwWithTypeErasure(Throwable t) throws T {
throw (T) t;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment