I'm having a problem with Exception handling in OOP-2. I have a method that throws an Exception, and I am creating the Exception with a String. The Catch block is trying to use the getMessage() method, but it is reporting as NULL. Any ideas? Sorry I didn't post any code, don't want to go too far...
Wait a minute, I'm trying to think of something clever to say...<p>Joel
That's a hard one to help out on without seeing the actual code. I'm assuming the following: Your method has the appropriate throws statement. Your method has a test that may throw new Exception... What exactly are you putting into your String? If you are passing it a variable of some sort, is it possible that the String is not getting initialized, and that is where the problem is, instead of your exception handling? Jason
Chicken Farmer ()
Joined: May 08, 2001
Also, make sure you are catching the right Exception. Depending on how you structured your try/catch block, you might be getting some other exception, and hence, no message is being created, so you see null. For instance, if what you are really getting is an ArrayIndexOutOfBoundsException somewhere, and you have catch( Exception e ), you could be catching it instead. Jason