Forums Register Login

Chained Exceptions

+Pie Number of slices to send: Send
Can we use the Chained Exception class provided at JavaWorld
in the assignment. Without changing can the same class be used. Will I be penalized if I use that class as it is.
[ April 08, 2003: Message edited by: Saraswathy Krishnamoorth ]
+Pie Number of slices to send: Send
JDK 1.4 offers chaining through normal exceptions, so you could use that. But no, you can't use third party classes.
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
+Pie Number of slices to send: Send
Thanks Max.
+Pie Number of slices to send: Send
If I have to use chained exception, userdefined Exception class has a memebr varialbe Throwable and it has to overlaod the following method
public FBNException(String message, Throwable cause) {
super(message);
this.cause=cause;
}
in addition to overloading public FBNException(String message) method. Also should have a method to retrieve the member variable.
Max, Is my understanding correct. Also how many levels of chaining can be achieved. For example,
Say Class A catches exception a1 and throws a new exception b1, then class B catches exception b1 and throws exception c1. Then class c catches c1. So is it possible to track exception b1 and a1 in c apart from exception c1. Please clarify.
+Pie Number of slices to send: Send
I'm not sure I understand the first part of your question, but as for the second, I believe you can nest exceptions to any degree of depth required.
M
+Pie Number of slices to send: Send
Max my first question is
1) If I have to use chained exception,
MyOwnException class should have a member varialbe Throwable and it has to overload the following method public FBNException(String message, Throwable cause)
in addition to overloading public FBNException(String message) method. Also MyOwnException class should have a getmethod to retrieve the Throwable member variable.
Is this correct.
Thanks Max.
[ April 08, 2003: Message edited by: Saraswathy Krishnamoorth ]
+Pie Number of slices to send: Send
Yes and no. It's true that constructors are not inherited, so you would provide your own. However, in jdk 1.4, the Exception class has been retrofitted with some nifty new methods, like initCause(sp?), getCause(sp?), that should help you out.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
+Pie Number of slices to send: Send
Thanks Max.
He does not suffer fools gladly. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 614 times.
Similar Threads
Chained Exceptions
need help with this problem
if anybody can shoe me the path for SCJD
filter mechanism in Servlets
Internationalization of Exception Messages
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:37:07.