Try Catch is not working

Hi all,

I have surrounded the body of the for loop with Try Catch, but still it is throwing error and terminating the process.

Exception Type Occurred is : System.NullReferenceException

Hi @Suman7

Could you provide a screenshot of the situation?

Would this simple project match yours?

As you can see in the output panel, it works on my end on the latest version of Studio (actually, the 2019.8.0 beta version).

I am using version 2018.4.3, and has handled the exception in the same way as you have mentioned in the screenshot. But instead of handling it in catch block its throwing the error and terminates.

Then unfortunately it looks like a bug, but one that was fortunately already fixed.
I can’t say for sure if the latest patch for your LTS version contains the fix, but it would be worth a try:

That is, of course, if updating to the latest Stable Enterprise edition is not an option ( 2019.4.4).

You can also try to update just the packages in your project first. The latest packages (19.7.0) such as UiPath.System will work with your version and could fix the issue.

2 Likes

How about this:

exception.Message.toString.

You’re creating an exception while accessing an exception object :slight_smile:

All the packages are already updated to its latest version.

Forum3

The problem is that after encountering the exception instead of entering to the catch block it is throwing the error and stopping the process.

Then it might be something that was fixed by the latest releases. If upgrading to the latest stable Enterprise is not an option, I would consider contacting our technical support here:

They might be aware of the solution / workaround.

That’s because you’re not catching a general exception in your catch block.

If you catch only a “Null type” exception, but the exception thrown is a different type it won’t be caught by the catch block.

Add another “exception” to your catch block and try again.

You must choose “Run program with mode Run or Run file not run mode Debug”. It will work fine

4 Likes