wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 37884
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not catching my own exception in my code
 
Similar Threads
writing methods which returns different Objects
running a method by it's string name
Need a solution to convert the object get from a database into a public key
JTable ClassCastException: Add rows dynamically
connection pool in UDB does not close connections