Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why should not caught Exception  RSS feed

 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I know that this is not recommended , but what exactly the reason ?
In which situation , it is recommended ?
In K&B book it is given that , you will not get proper message ( log ) if you will use this , I am not getting why ?
e.printStackTrace() will be called based on object ( Exception ) type ( late binding ) , so I think we will get proper message .

please help me .
Thanks in advance .
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One reason may be this : In real project , we never just write printStackTrace() method in a catch block , we do something specific depends on exception type .

Like if there is FileNotFoundException then we can provide any local file . So we catch exception separately & do something specific for them .

In which situation , it is recommended ?

Well , I don't think , it is recommended in any situation .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!