This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You can call getMessage() without casting it to another class; you'll get the appropriate message. If you mean you want to create a message based on the class, then you certainly could use getClass().getName() to get the name of the Exception class.
Heh - that's pretty horrid. Though I would point out for Christopher's benefit that if you're trying to extract some sort of String description of an exception, toString() is often a better choice than getMessage() - at least for a "general" catch block that catches something like all Exceptions or all RuntimeExceptions. The toString() method usually gives you the exception class name followed by the message (if that message is not null). In many cases the exception name is the error message (or an important part of it), and so you can't assume getMessage() by itself will be sufficient to give you useful information. Unless you've caught a specific type of exception which is known to have reliable messages (e.g. one you wrote yourself, or have tested enough to trust).
"I'm not back." - Bill Harding, Twister
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com