|
-
July 7th, 2010, 02:56 AM
#13
Re: newbie: exception handling (and Eclipse)
 Originally Posted by keang
As dlorde and I have both said you put the handler at the point at which you can do something useful and as close as possible to the place the exception is thrown. If your handler can do what you want it to do where you have it then leave it there - don't move further from the problem than you have to.
Having said that you haven't done anything useful in the code you have shown. You've just committed the cardinal sin of catching the exceptions and doing nothing at all, not even dumping the stack trace. This just hides the fact that the exception has even been thrown. Always do something in the catch block even if it is just calling the exception's printStackTrace() method.
you're right. My question was only if the try/catch will be "called" fine. In the try/catch I would put simply a message with System.exit(-1) because there's nothing to recover (the XML file is not well written).
I only wonder if in my case here above exceptions are unuseful! Is the meaning of exception just recovering something?
Yesterday I wa thinking this: If I don't put try/cach at all the program the program will arise exception (and this is bad); I thought that putting try/catch was even to avoid the program arises exceptions at all! I thought this, but now I suppose this was wrong! try/catch just helps to RECOVER (but the exception will arise anyway). Is that, please?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|