Checked versus unchecked exceptions
Avoid basic style errors
If an exception occurs outside a try..catch
block, the
exception simply propagates "up" to the caller.
If an exception occurs inside a try..catch
block, then
the control flow can take different forms. Here are the cases, along with
indicators for which code blocks are included in the control flow:
Case | try | catch | finally | bottom |
try throws no exception |
y | - | y | y |
try throws a handled exception |
y | y | y | y |
try throws an unhandled exception |
y | - | y | - |
Here, "bottom" refers simply to any code which follows the finally block,
as shown here :
final class Bottom { void doStuff() { try { //..elided } catch( Exception ex ) { //..elided } finally { //..elided } //any code appearing here, after the finally //block, is "bottom" code } }