Hi:
I want to modify code, with method calls:
A > B > C > D ( eg method A calls B ; method B calls C; etc.)
A_Prime > B > C > D
Want to throw an exception in D -- to propogate up to A
but do NOT want to throw an exception in D -- to propogate up to A_Prime
eg, so it changes D to D_Prime throws <some exception>
A > B > C > D_Prime
A_Prime > B > C > D (stays same, with out throwing exception)
If I modify code to add a parm when calling B from A, that is not used when calling B from A_Prime, its easy enough to modify:
For instance:
change so A calls B with newParm & old Parm list
change so A_Prime calls B with a (dummy newParm) & old Parm list
and propagate down the call stack fairly painlessly
but in the above scenario where one path is changing to throw an exception, but another isn't
is there an easy way to do that?
Eg, <A, A_Prime, B, C> code is NOT changing.
D has a slight change so that it can call a method that can throw an exception when called indirectly by A
It seems a pretty big pain to change so the A_Prime > B > C > D path does NOT throw an exception
but A > B > C > D DOES throw an exception.
I could put throws clauses in A_Prime > B > C > D path but would prefer to avoid -- just because I imagine looking at it
in future would be confusing when there is no chance of an exception from that path.
At least to me, checking the (dummy newParm) is "self-documenting" and fairly straight forward -- but it may just because
I have a lot of experience with that kind of changes. I am more inexperienced with exceptions.
Maybe throwing exceptions in A_Prime > B > C > D path is SOP, but I would like to see if someone more experienced
has a better solution.
I googled the following w/o finding any good insights:
java method one path throws exception one does not
java one path throw modify old code
java throw "modify old code"
java throw
Thanks in advance!