You need to sign in to do that
Don't have an account?
stela 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/
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/
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!!