Try Catch on Change Type Error

Hi, I tried to convert String to Double within a Try Catch loop. If conversion is unsuccessful, it will throw an exception and set the Double variable as 0. It was working fine in the past. I’m not sure why it is not working now.

The input variables are:
A list showing five different items with their corresponding prices, except for the last one which is labeled "Item not found". (Captioned by AI)

The UiPath Studio flow are:

The error thrown below.

Hi,

It seems GlobalExceptionHandler works. For now, can you try to remove Handler as the following image?

Regards

2 Likes

Hi @vincentlimwy

Use TryParse instead of relying on exception handling:

Double.TryParse(stringVariable, doubleVariable)

This prevents the need for a Try-Catch and ensures doubleVariable = 0 if conversion fails.

If you still suspect a Global Handler issue, check if the handler is interfering by temporarily disabling it and running the workflow.

If you found helpful mark as a solution.
Happy Automation

1 Like

@vincentlimwy

If Global exception handler is not enabled - Could you please add one more catch exception for

System.InvalidOperationException and set the value as 0 there as well

1 Like

Thank you Yoichi for your help. I followed this method and it works!

2 Likes

Thank you Prashant for your reply. I used the Global Handler method mentioned above and it works. Thank you for the quick help!!

1 Like

Thank you Sharazkm for your reply. I used the Global Handler method mentioned above and it works. Thank you for the quick help!!

1 Like

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