function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
stela jonesstela jones 

Is it possible to keep other statements in between ‘try’, ‘catch’, and ‘finally’ blocks?

It is not recommended to include any statements between the sections of  ‘try’, ‘catch’, and ‘finally’ blocks, since they form one whole unit of the exception handling mechanism. 
try
{
    //Code which is monitored for exceptions.
}
//You can’t keep statements here
catch(Exception ex)
{
    //Catch the exceptions thrown by try block, if any.
}
//You can’t keep statements here
finally
{
    //This block is always executed irrespective of exceptions.
}

https://plumbingadvice24.com/how-to-install-abs-pipe-and-fitting/
AnkaiahAnkaiah (Salesforce Developers) 
Hi Stela,

No, its not possible to add the code in between the ‘try’, ‘catch’, and ‘finally’ blocks.

Apex uses exceptions to note errors and other events that disrupt the normal flow of code execution. throw statements can be used to generate exceptions, while try, catch, and finally can be used to gracefully recover from an exception.

Refer the below help article.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_statements.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_trycatch_example.htm

If this helps, Please mark it as best answer.

Thanks!!
 
Vishal GarryVishal Garry
Thanks for your helpful reply. Glad to know more about it. Carry on!