Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not catching my own exception in my code

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ?
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer to the above post that I have explained.

All the best.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic