Try catch doesn't work

In Studio 2023.12.0 version, “Could not find the UI element corresponding to this selector” doesn’t work in try catch now … it worked before… and the language sometimes in English sometimes in Chinese… don’t now why

Hi @372862593

Instead of using the SelectorNotFoundException and ElementOpeartionException, use the System.Exception it will handle all the exceptions. In the Catch block insert a log message and give like this, exception.message in log message activity.

Check the below image for better understanding,
image

exception.message means shows the message of the exception.
exception.source means shows the which activity got the exception.

Hope it helps!!

Hey @372862593 ,
Have you added anything in Catch Block?like a log message and a Throw/Rethrow activity?

Just to be clear, this doesn’t ‘handle’ the exceptions in the classic understanding of exception handling & its often good to have handler blocks for specific exception types. Your suggestion will basically ignore all exceptions and only log the error message.

Its in my opinion, not good to do this since you throw away alot of useful information about the exception, you cannot even see what type of exception it is if you log just to message, and if there is an inner exception you cannot see that at all, these are extremely useful if you get an error during an assign operation since the inner will typically tell you why the value cannot be assigned.

Instead I would strongly suggest you log the full exception be serializing it to a string, after that rethrowing or taking some other action that actually handles to exception.
The code posted here would mean you needed to ‘handle’ the exception later for real by trying to figure out if an exception had occurred, perhaps by empty variables or something, and then decide what to do.

@372862593

Try with this exception type UiPath.UIAutomationNext.Exceptions.NodeNotFoundException

to confirm the exception type you can open the exception details from the locals panel and check the exception type there

cheers