Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tool to identify problems in catch blocks

 
Prince Manchanda
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for a tool (may be build time or eclipse plugin) that can help me to identify if I am not logging the Exception trace/message.

We have a legacy application that has try catch block in which a custom error message is logged. The exception is not logged and is not thrown. So, when a problem occurs, there is no stack trace in the log files that would help to debug the issue. An example of this is:



i need a tool like Coverity or Checkstyle that can help me to identify all such occurrences in my code base.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like FindBugs can warn you if an exception is "dropped": see this. There might be other static code analysis tools that would warn you about the same.

It probably won't warn you if it is not properly logged, though. That should not be so much of a problem, you should log exceptions at the topmost level of your program, and probably install an uncaught exception handler to log those that might otherwise be missed. (You might need to setup a Swing-specific uncaught exception handler if you're using Swing.) These places should be few and thus relatively easy to review.

If you're logging and dropping an exception at a lot of places in code, this won't help you. Such a design would look very suspicious to me, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic