try catch Query

Hello All,

When i’m throwing error from inner try() block i’m not able to catch error in inner catch() block,it is going in outer catch() block?Can anybody tell me exactly what is happening in below code and what is the role of ttsbegin and ttscommit in below code?

try()

{

//Some code

ttsBegin;

try

{

throw error("");

}

catch

{

}

ttsCommit;

}

catch

{

//some code

}

Thanks in advance

There is nothing in your inner catch.

This can help you, https://msdn.microsoft.com/en-us/library/aa893385.aspx

It is the standard behavior, please refer to this link and look on the sample 5 https://msdn.microsoft.com/en-us/library/aa893385.aspx

Use the ttsbegin and ttscommit inside the second try statement.

e.g.

try
{
//Some code
try
{
ttsBegin;
throw error("");
ttsCommit;
}
catch
{
}
}
catch
{
//some code
}

Use

Hi Kranthi,

Its just a sample,i’m asking about if you throw error from inner try why it is not caught in inner catch?

Hello Hariharan,

I got your point but i’m still not able to figure why its happening,what is the reason behind this behaviour?

Could you please explain the concept in more detail?

Why is it happening? Because that’s how X++ has been designed, therefore any other behaviour would be wrong. The problem is only in your incorrect expectations.