[JAVA] Item 73: Throw exceptions appropriate to the abstraction

73. Throw exceptions suitable for abstraction


// Exception Translation

try {

    ... // Use lower-level abstraction to do our bidding

} catch (LowerLevelException e) {

    throw new HigherLevelException(...);

}


// Exception Chaining

try {

    ... // Use lower-level abstraction to do our bidding

} catch (LowerLevelException cause) {

    throw new HigherLevelException(cause);

}

Recommended Posts

Item 73: Throw exceptions appropriate to the abstraction