The correct way to do this is probably to break the method by putting the try-catch block in a separate method and using the return statement:
public void someMethod() { try { ... if (condition) return; ... } catch (SomeException e) { ... } }
If the code contains many local variables, you can also consider using break from the marked block, as suggested by Stephen C :
label: try { ... if (condition) break label; ... } catch (SomeException e) { ... }
aioobe Jun 30 '11 at 11:37 2011-06-30 11:37
source share