how can I find where an exception is thrown in the context of call ??
Since I have to dela with (sigh) long methods, I often need to find
where an exception is thrown in the context of a methos call.
eg,:
void mylongMethod() {
try {
object1.someMethod1();
object1.someMethod2();
object2.someMethod3();
object3.someMethod4();
object4.someMethod5();
this.method6()
ClassX.staticMethod7();
}
catch (ExceptionType1 e1) {
...
}
catch (ExceptionType2 e2) {
...
}
}
I want to find which lines in the try/catch block may throw e2.
I do not want to find all places in code where e2 can be thrown, only
those within the method that I am examining ...
'find/highlight usages in file' is not doing the job, IMO.
as it doesn't tell wen the exc is thrown in other classes invoked in the
current method
neither 'find usages' for the exception class is suitable,
as it will show many places that are not ni the context of the given all
stack.
nonetheless, if I remove a catch clause, idea highlights the fact that a
specific line throws an exc that is uncaught.
if this serach I'd like to perfrorm is not available as of now, I'll
open an SCR/request.
Edo
Please sign in to leave a comment.
You can comment the catch block so that IDEA will complain about "exception thrown but not caught" in line X - exactly what you need.
Oh, sorry, you've already mentioned this option. So - what's the problem - you know in what line the exception is thrown. Isn't it what you're asking for ?
Edoardo Comar wrote:
Press ctrl-shift-f7 on the "catch" keyword. Also works for "throws" in
a method signature.
See http://www.eugenebelyaev.com/begblog/idea/000008.html
Jonas Kvarnström wrote:
>> Since I have to dela with (sigh) long methods, I often need to find
>> where an exception is thrown in the context of a methos call.
thanks, this is what I was looking for :)
Evgeny Goldin wrote:
Well I do not want to try coment the catch clause,
but anyway the answer to my question s below ....