Created
January 9, 2020 09:24
-
-
Save danielkec/e6c6a317b41bb54a29455117d41d44a3 to your computer and use it in GitHub Desktop.
throwUncheckedException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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