• 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

Using Throwable.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ONE OF MY PEERS SUGGESTED THAT THERE WERE SOME PROBLEMS WITH USING THROWABLE BUT HE WAS NOT VERY CLEAR. WOULD SOMEONE LET ME KNW WHAT ALL POTENTIAL PROBLEMS OCCUR WHEN USING THROWABLE TO HANDLE EXCEPTIONS.
[ September 22, 2005: Message edited by: Michael Ernest ]
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THE THROWABLE CLASS IS THE SUPERCLASS OF ERRORS AND EXCEPTIONS,
IT'S BETTER TO AVOID IT TO HANDLE ALL EXCEPTIONS. CATCH SPECIFIC EXCEPTION & HANDLE IT.


Is the above text readable .. please try to post it properly.

[ September 22, 2005: Message edited by: Srinivasa Raghavan ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably what he meant was that if you write this:



then that catch block will catch not only exceptions that your code throws, but also exceptions due to unrecoverable problems like OutOfMemoryError, StackOverflowError, and worse. These are all subclasses of Error, which is one of two subclasses of Throwable (the other one is Exception). In general, if you want to catch generic problems, use Exception; then things that are meant to be fatal, will be.

This isn't to say that you should never catch Throwable -- but that you should account for all the possibilities when you do so.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

By EFH :- then that catch block will catch not only exceptions that your code throws, but also exceptions due to unrecoverable problems like OutOfMemoryError, StackOverflowError, and worse. These are all subclasses of Error, which is one of two subclasses of Throwable (the other one is Exception). In general, if you want to catch generic problems, use Exception; then things that are meant to be fatal, will be.



This is the difference between an author & a green horn. Thanks for the detailed reply EFH.
 
Hot dog! An advertiser loves us THIS much:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic