Displaying Variables upon Failure

I have a bot that stores information as it chugs along. When the process is over, the variables get written to an Excel. My bot will occasionally fail as it is running. Is there a way to display what specified variables are in a message, so I can view the variables at the point of failure.

Example:
for each row:
start process
x = “”
if column1 =2 :
x = “two”
if column2 = True
x = x+“True”
end process
write to excel

??? Example Question ???
If my bot failed at if column2 = True, could I log that x=“two” or x=“”, so that I still have that information

HI,

How about using TryCatch?

image

Or simply add LogMessage activity before or after the IF activity.

Regards,

Hi,

Surround your process with try catch block. In catch section you can print the x value.

Thanks

Hi @arichmond1,

Welcome to the UiPath Community!

Make sure your x variable is declared(or scope of the variable) outside and before of the for each row activity.

Then use below approach.

Try
 for each row:
 start process
 x = “”
 if column1 =2 :
 x = “two”
 if column2 = True
 x = x+“True”
 end process
 write to excel
catch
 log yuour x value

Thanks,
Ashok :slight_smile:

@arichmond1,

Remember

Scope of the variable x is important if it’s inside for each only then you won’t be able to get last assigned value in catch.