This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Not catching my own exception in my code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Not catching my own exception in my code" Watch "Not catching my own exception in my code" New topic
Author

Not catching my own exception in my code

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Dear all i have my own exception


na i had one class in which i'm throwing my exception


Here Im Throwing my own exception in catch block .

And I had my class


And when ever the sql exception occurs it ll get catched in TableDetails class but it is not throwing to the above class mentioned here im getting exception which i ahd thrown in TableDetails i just checked up in Tabledetails catch block there its getting printed and also i checked in my exception class also there also its getting printing but that exception is not getting to above class Please help me


Creativity is nothing but Breaking Rules
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213

And when ever the sql exception occurs it ll get catched in TableDetails class but it is not throwing to the above class mentioned here im getting exception which i ahd thrown in TableDetails i just checked up in Tabledetails catch block there its getting printed and also i checked in my exception class also there also its getting printing but that exception is not getting to above class Please help me


Sorry, it is hard to read your sentence without comma and fullstop ... can't help you at this point.

Can you rephrase your question ?


SCJP 6, SCWCD 5, SCBCD 5
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
I think I understand what is your problem

You have a problem of lost exception !

because in your finally clause , you are using a "return".


There is two situation which will cause you to have the problem of lost exception (i.e. causes the exception throw in catch block lost):
1) in your finally block, there is code which throw exception
2) in your finally block, there is "return" code


Please try to move your "return" code out from finally to the last line of code in that method.

Hope this help you ~
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Dear all
I have my own exception

And i had one class in this class i'm Throwing this exception


The calling Function



Here im not getting Exception when ever TableDetails throw a exception one thing i came to know about that is if i remove return statement in TableDetails class from finally block and placed at the end it ll work as fine

Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
Please refer to the above post that I have explained.

All the best.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
By the way, you ought not to declare an additional Throwable field in your Exception class. all you need is four overloaded constructors to match the constructors of the Exception class and they only need a super(something); line in.
 
 
subject: Not catching my own exception in my code