Hi
I have a problem in which I need to invoke a method on catching "ObjectNotFoundException".Now this invoked method also throws an exception; can I catch it in the same try/catch block ; cause nested try/catch are not allowed any way.
try
{
//find something
//update if found
updateRow(arguments)
}
catch (ObjectNotFoundException e)
{
//insert some data in the database using a method
// insertRow (which throws an exception insertException)
insertRow(arguments);
}
catch (insertException e) //IS THIS ALLOWED ?????????
{
//do some logging
}
catch (updateException e)
{
//do some logging
}
I think this wont work ; cause (insertException) is not thrown in "try" block . what say u?
Thanks
Jack
-
ObjectNotFoundException issue (5 messages)
- Posted by: lkbm lkbm
- Posted on: December 19 2000 13:20 EST
Threaded Messages (5)
- ObjectNotFoundException issue by lkbm lkbm on December 19 2000 13:43 EST
- ObjectNotFoundException issue by devendra Singh on December 19 2000 14:12 EST
- ObjectNotFoundException issue by lkbm lkbm on December 19 2000 14:31 EST
- ObjectNotFoundException issue by Vijay K on December 19 2000 02:34 EST
- ObjectNotFoundException issue by lkbm lkbm on December 19 2000 02:34 EST
- ObjectNotFoundException issue by lkbm lkbm on December 19 2000 14:31 EST
-
ObjectNotFoundException issue[ Go to top ]
- Posted by: lkbm lkbm
- Posted on: December 19 2000 13:43 EST
- in response to lkbm lkbm
Hi
I again checked my java knowledge base and its true that once a catch{} has been executed ; all other catch{} are ignored .So I guess "insertException" will be caught by the program which called the current program.
Can there be any other way of handling this ; I mean the situation in which if an object is not found ; insert it.
Thanks
jack -
ObjectNotFoundException issue[ Go to top ]
- Posted by: devendra Singh
- Posted on: December 19 2000 14:12 EST
- in response to lkbm lkbm
Hi,
Let me know if this helps. You can create nested try catch block as follows
try
{
}catch(ObjectNotFoundException onfe)
{
try
{
}catch(InsertException ie)
{
}
}
Cheers,
Devendra -
ObjectNotFoundException issue[ Go to top ]
- Posted by: lkbm lkbm
- Posted on: December 19 2000 14:31 EST
- in response to devendra Singh
Hi
Can i create nested try/catch block?I used to think that nested try/catch blocks are not allowed?
Is it part of java 1.3? or I was ignorant of it?
Jack -
ObjectNotFoundException issue[ Go to top ]
- Posted by: Vijay K
- Posted on: December 19 2000 14:34 EST
- in response to lkbm lkbm
this is definitely allowed, i've been using this in jdk1.2. -
ObjectNotFoundException issue[ Go to top ]
- Posted by: lkbm lkbm
- Posted on: December 19 2000 14:34 EST
- in response to lkbm lkbm
Hi
can a catch block return to the calling program?
I mean
try
{
return 0 ;
}
catch (Exception e)
{
return 1 ;
}
I guess this is allowed?
Sorry for this elementary questions ; havent programmed much in java ; so sometimes my fundamentals complain :-)
Jack