| Author |
chained exception
|
mu gaandimara
Greenhorn
Joined: Aug 04, 2009
Posts: 10
|
|
|
What is chained exception ???
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
When you wrap an exception that is the root cause in another exception.
The Servlet Spec makes use of it.
the doGet, doPost etc. methods of HttpServlet throw a ServletException.
Imagine code like this.
You chain the SQLException together with the ServletException since you cannot throw it yourself (the signature does not allow this)
ServletException itself has a method called getRootCause() that returns the Exception you chained.
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Moving to Beginning Java.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
mu gaandimara
Greenhorn
Joined: Aug 04, 2009
Posts: 10
|
|
|
Can we wrap a Checked Exception in a RuntimeException ??
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Sure. If the class does not have a constructor that has a Throwable parameter for the cause, you can always set the cause later:
And please read your private messages regarding an important announcement.
Thank you,
Rob
|
 |
mu gaandimara
Greenhorn
Joined: Aug 04, 2009
Posts: 10
|
|
|
thank you
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
mu gaandimara wrote:
Please check your private messages for an important administrative matter.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
 |
|
|
subject: chained exception
|
|
|