Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

try catch finally sequence  RSS feed

 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am very well aware of the situation in which the try, catch and finally work but i have a program code for which i am not able to determine what the sequence is..

Here goes the code:


Now my question is what happens if there is a Sql error in the case 1, will the finally be executed and then the error is caught or only the error is caught without finally.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "finally" is executed before the catch blocks are entered.
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so what happens to the exception, is it caught or left.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It goes "through" the finally block and is caught.
 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if an exception occurs in the try block of case 1
*first finally block of the try in case 1 will be executed
*exception will be handled by the catch block of the outer try since you have no catch block in the case 1's try
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!