The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Exception-Handling Antipatterns
Subject:  Use toString instead of getMessage
Date:  2006-04-07 05:32:10
From:  ricon


imo you should add one point.

Instead of getMessage() which may return null, which in some cases may lead to useless output or worse NPEs, use toString, which returns the Throwable's classname + getLocalizedMessage if it is not null.
In this way you will always get at least the information which exception arised.



 Feed java.net RSS Feeds