Skip to content

Instantly share code, notes, and snippets.

@golonzovsky
Last active December 16, 2017 12:02
Show Gist options
  • Save golonzovsky/5680169 to your computer and use it in GitHub Desktop.
Save golonzovsky/5680169 to your computer and use it in GitHub Desktop.
package com.test;
import java.sql.SQLException;
public final class UncheckedThrow {
public static void throwUnchecked(final Exception ex){
UncheckedThrow.<RuntimeException>throwsUnchecked(ex);
}
public static <T extends Exception> void throwsUnchecked(Exception toThrow) throws T{
throw ( T ) toThrow;
}
public static void main(String[] args) {
throwUnchecked(new SQLException());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment