Rethrowing of exception in java has improved starting from Java 7. We can now specify more specific exceptions using throws keyword. Before java 7:
1 2 3 4 5 6 7 8 9 10 11 12 |
public void someMethod(String testStr) throws Exception { try { if (testStr.equals("SomeThing")) { throw new UserException1(); } else { throw new UserException2(); } } catch (Exception e) { //Do some processing.. throw e; } } |