I'm reviewing code for a colleague and I encounter a piece of code similar to this:
public X Foo1(Y y) throws Exception {
X result = new X(y);
result.Foo2();
return result;
}
I believe there is no need for throws Exception
part but I'm having difficulties justifying this. It might make sense if it was more specific Exception
(FileNotFound
, NoMemory
etc.) but as it is I think it is unnecessary. Can someone give me some reasons what problems this can cause and why it is bad practice? Or is this code ok?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…