This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes exception chaining Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "exception chaining" Watch "exception chaining" New topic

exception chaining

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Can someone tell me why do we use exception chaining, any practical example for the same ?
David Newton

Joined: Sep 29, 2008
Posts: 12617

To keep the original exception. throw new Exception(oldException)

Did you try searching for "exception chaining"?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38062
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019

Please SearchFirst.
The first two Google search results for "Exception Chaining" would give you a better explanation with some practical examples.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

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.

I agree. Here's the link:
subject: exception chaining
Similar Threads
Exception Chaining
cushioning exception from bottom up...
Exception Handling
NX: concerning exception handling