Checked exceptions are problematic - I heard they are best described as a “Failed Experiment”.
Runtime exceptions are a pretty good way to handle sticky situations. For example, you often have a large, high-level thread that is expected to be run by Forever. In this stream (inside different methods) there can be 30 places that are read from the database or interact with some other unstable source.
If this data source fails, you always want to process it in the same way - reconnect, and then restart the main loop.
This is very easy to handle in a high-level stream, but if each object processes it itself, it distributes horrible error checking code throughout the project.
So, the answer: feel free to wrap your flag in an excluded exception from the runtime if there is nothing useful at this level - and I would advise NEVER throw a checked exception if there is something that caller SHOULD handle immediately (which almost never it happens - most problems can be handled at a higher level).
By the way, I do this a lot and almost never use new exceptions - you can reuse existing ones if you have no reason to distinguish exceptions at a higher level.
source share