Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Catching SecurityException  RSS feed

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lot of library methods in the core JDK throws SecurityException.
See JMXConnectorFactory.connect as an example.
My question is: as a client, do I need to catch SecurityException ?
Can one actually recover from such an exception?
In my experience, most of the application code I've seen just ignores it.
Your opinions?

Thanks

Pho
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Considering that it's a runtime exception, it should not make much sense to catch it, unless you'd like to do something else (logging?) when it happens.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you want your user to see ... a nice error message or a stack trace? Can the user take any corrective action and try again? Things like that will factor into your decision.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!