aspose file tools*
The moose likes Beginning Java and the fly likes Exceptions -- How Do You Know Which? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exceptions -- How Do You Know Which?" Watch "Exceptions -- How Do You Know Which?" New topic
Author

Exceptions -- How Do You Know Which?

Tasty Bread Products Inc.
Greenhorn

Joined: Jan 16, 2002
Posts: 1
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?


<img src="biggrin.gif" border="0">
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
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.


Matthew Phillips
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
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 ]

Sreenivasa Majji
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions -- How Do You Know Which?