@M guy I Have gone through your doubt and found this:-
I have a class as follows;-
public class testGoverner {
Public static void insertcontact(){
try{
for(Integer i=0;i<1500;i++){
Contact c = new Contact();
c.LastName='system'+i;
insert c;
}
}catch(DmlException e){
system.debug(e.getMessage());
}
finally{
system.debug('Hit the governer limit');
}
}
}
When I run this class using execute annonymous window, I got error System.LimitException: Too many SOQL queries: 101
So, I tried calling this in another class as follows:-
public class TestClas {
public static void test(){
try{
system.debug('check');
testGoverner.insertcontact();
}finally{
system.debug('hit governer');
}
}
}
And again run it, so again I got the same error System.LimitException: Too many SOQL queries: 101
So in both the cases, it gets terminated without going to finally block and no debugs log got generated.
then I tried calling this class with Visualforce page and execute it on click of button as follows:-
<apex:page controller="testGoverner">
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons>
<apex:commandButton action="{!insertcontact}" value="check"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
And Got this:- Too many DML statements: 151
Error is in expression '{!insertcontact}' in component in page testgovern: Class.testGoverner.insertcontact: line 7, column 1
This time debug log get generated but finally statement does not get executed.
Note:- even catch block does not get executed.
So I can say you are correct that your code terminated at the point at which the limit is exceeded. Even if you have a finally block, it will not get run since your code has terminated.