Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception chaining

 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell me why do we use exception chaining, any practical example for the same ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To keep the original exception. throw new Exception(oldException)

Did you try searching for "exception chaining"?
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if you can find a copy of Thinking in Java by Bruce Eckel; as far as I can remember he gives good examples. His opinion about Exceptions in the 3rd edition is completely different from the 4th edition, however
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4252
227
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please SearchFirst.
The first two Google search results for "Exception Chaining" would give you a better explanation with some practical examples.
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is about how an exception is related to another ...

let us say ... you get an exception say SQLException which happened due to some sql related confusion but in actual it is a I/O Exception ...

so the two exceptions are chained together ...

take a look at the complete reference ... although it is not enough but might help you understand some.

Lucky
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic