Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception-type

 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I'm not clear with line in HFSJ page 595.(there are no dumb questions)

Question:
what are you allowed to declare as an exception type in <exception-type>??Answer:

Anything that's throwable so that includes java.lang.Error,runtime exceptions, and any checked exception(as long as the checked exception class is on the Container's classpath,of course)


Can anyone please expand this and expalin me clearly.
Thank you very much
shanthi
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Question:
what are you allowed to declare as an exception type in <exception-type>??Answer:

Anything that's throwable so that includes java.lang.Error,runtime exceptions, and any checked exception(as long as the checked exception class is on the Container's classpath,of course)


The <exception-type> requires the full class name of the Throwable type, which we want to catch by this mechanism. As the type is "Throwable" we can catch Errors, Run-time Exceptions and Checked Exception. Checked Exceptions are ususlly declare in the method defination throws clause, if you want to propogate the exceptions to the outer world (i.e to Exception handling mechanism).

any checked exception(as long as the checked exception class is on the Container's classpath


If it is required to define custom exceptions for exception handling the user usullay define the checked exceptions. So these checked exception clsses must be accessible to container , so it should be in the container's classpath. If the containe can not find Exception class it will be error.

Hope it help

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic