• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to understand rethrows exception  RSS feed

 
Asish Dash
Greenhorn
Posts: 7
Java MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any please explain me what is rethrows exception ,with a programme...
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is throwing an exception from a catch block.
 
Tim Holloway
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://en.wikipedia.org/wiki/Hot_potato_%28game%29

Except that you can only throw upwards on the call stack.
 
Niraj Jha
Ranch Hand
Posts: 63
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rethrows is in terms of throwing exception again from catch block.
We generally use it when we are not sure how it should be handled that's why we throw it agian and facilitate client to handle it.
 
Tim Holloway
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, a common use is to decorate the exception (add additional meta-data unavailable at the lower level where the exception occurred). This is often done by creating and throwing a new Exception whose parent is the original Exception.

Some systems such as Hibernate JPA catch JDBC-specific exceptions and normalize them to the standard JPA exceptions.
 
Campbell Ritchie
Marshal
Posts: 56596
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Pankaja Shinde
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

something like this

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!