Problem Statement
When would you create a custom checked exception versus a custom unchecked exception?
Explanation
Create a checked exception to force callers to acknowledge a recoverable domain error—like a business rule violation or a missing required configuration. Create an unchecked exception when the failure indicates a programmer mistake or an unexpected state that typical callers cannot handle—like illegal arguments, null misuses, or invariant violations. Use descriptive names and include context in the message.
Practice Sets
This question appears in the following practice sets:
