Journal DEBEDb's Journal: Java exception trick 3
This trick is due to catamount, an excellent programmer with whom I have an honor of currently working .
Often one does not want to declare exceptions to be thrown. An example that comes to mind is a use of a Visitor pattern, because one may want to declare a common interface specifying a visitor (that the accepting classes have to accept), but the differing implementations of visitors may have quite differing errors (and having some sort of VisitorException means that the exceptions are then classified by who throws it, and "not so hot on why".
However, along the call stack, some callers may be aware of this. So what one does is wrap an Exception in a RuntimeException, catches the latter in the code that's aware of it, and unwraps it.
Cute, eh...
Re:Nope (Score:2)
Java too, but "cuteness" (or "perversity") factor
in fact is increased when something with limited
perceived functionality can be made to do
something useful in a non-straightforward way.