Can we print any other variable in catch block

I have one variable in my try block and in catch block i want to print that variable value.

Is it possible or not?

Can someone help me on this?

Inside the catch you can take any actions, including printing the variable using log or write line.
The only situation when you might not get any output is if the assign activity for the variable itself is the one that triggered the catch, since the assign didn’t take place and threw an error.

1 Like

it means , we can not log that variable value in catch
? right

If the assign activity of the variable is the one throwing the error, the variable will be empty anyway so no. In all other cases yes, you can print it.

1 Like

My question is not that, Can i print a variable in catch block which i have in try block.
It is a normal variable.

Because i can see its value in try block but not in catch

Yes, in this case you can!


Yes - you can print the variable value in exception block - with one small change in the variable scope.
Change the variable scope to above try/catch block sequence - then variable will be available entire try/catch block.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.