• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

when we get need to use throwable?

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error and Exception classes are sub classes of Throwable - it is fine.
in method when we get need to "throws Throwable" instead of "throws Exception".
If I assume Throwable is used to catch both Errors and Exceptions, then can we catch Errors by using try-catch(Throwable t).
I think we should not catch Errors. These Errors goes directly to JVM.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually, an Error is caused by some unusual state and, in most cases, you wouldn't want your application to go on in such a state as you don't know what might be happening.
However, I can imagine there might be a case in which you would want an application to continue on, at all costs. Maybe, even if the application can't go on, perhaps it can fail gracefully by catching an error.
 
reply
    Bookmark Topic Watch Topic
  • New Topic