• 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

Exceptions -- How Do You Know Which?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you know which exception(s) your methods should throw? Is there documentation and/or guidelines for this available as part of Sun's SDK?
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The compiler informs you, in the case of "Checked" exceptions, if you do not enclode your code withing a try/catch block that catches the appropriate exception or it's superclass. Or fi you do not indicate that your method throws the exception or it's superclass. It is not a requiremen that you catch the other exceptions. You can check the API for more details.
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tasty Bread,
Javaranch has a naming policy. Please re-register with a name that complies with that policy so that you may continue to post here. Thanks.
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java APIdocumentation tells about all the possible exceptions thrown by methods. However these are all checked exceptions, means that they will be checked at compile time. However the rumtime exceptions such as NullPointerException should be handled separately, unfortunately these are not available in API documentation.

Originally posted by Tasty Bread Products Inc.:
How do you know which exception(s) your methods should throw? Is there documentation and/or guidelines for this available as part of Sun's SDK?


[ January 16, 2002: Message edited by: sreenivasa majji ]
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get a complete list of all the runtime exceptions by checking the Throwable \ Exceptions \ RuntimeExceptions hieratchy in the API.
java.lang package also lists all the exceptions and errors included in the package.
HTH
 
a wee bit from the empire
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic