How to manage error in macro with uipath

I manage error in excel (macro) with parallel for KillProcessExcel as below.

Flow in killProcessExcel as below.

Now it’s error in excel ----> uipath kill Excel complete.

But I don’t want show error after run finished.

Please guide me for solve it.

Hi

Instead you can cover this sequence of activities with a TRY Catch block so that if any error comes it won’t stop and also won’t show any error

Cheers @fairymemay

@Palaniyappan Yes, I use in TRY.

How to mange in CATCH ?

Catch choose the exception type as System.Exception and have it filled with just a log message with a note like this

“Bot failed with system exception”

If any issue occurs in try block then it will caught by catch block and this log message will get written

It won’t stop or show any error as well

Cheers @fairymemay

Hi @fairymemay ,

As suggested by @Palaniyappan , use a try catch. The activity which is giving error Right click on it → then Surround with Try catch-> in the catch section selection System.Exception and use a Log message with Exception.message, this will not stop the code and will print the error as well.

Thanks

Is it working as expected @fairymemay

Hi @fairymemay,

As @Palaniyappan suggested, you need to enclose the activity with Try-Catch activity.
In the try block, you have to use the logical sequence into the try block, and in the catch, create a System.Exception and inside that create a log message with Log level Error (to notify it is an error) and in the message enter the exception variable (Sample Screenshot below)

image

So, when the error occurs, in the catch block the error will be caught and written into the output panel. So, you can able to view the error in the output panel for reference.

Hope so this helps you to solve your issue.

Regards,
@90s_Developer

@90s_Developer @Shikhar_Tandon @Palaniyappan

Now I use TRY CATCH but in TRY in use invoke.

Why error in TRY but not work in CATCH ?

Try block is used to catch the exception if any of the activities kept inside try block fails

Once being caught it will be sent to CATCH block instead of stopping the bot

In catch block we can either retry the same set of activities or other set of activities or just have a log message like how we have now

This is how try catch activity works in terms of exception handling

For more details on this activity have a view on this

Cheers @fairymemay

1 Like

@fairymemay,

For a clear understanding,
in the try block, what logical sequence which you have built need to be given, so when any error or issue occurs in the try block that will be caught in the catch block.
In a simple way, the error or issue raised in the try block will be caught by the catch block. That’s it.

Regards,
@90s_Developer

1 Like

@90s_Developer yes, I understand you.

But I don’t understand about my flow.
It have error in sequence that in Try (red square)
But not go to catch for run.

In try error as below.


image

Hi

You are running in debug mode I believe

Run in normal mode

Click on the drop down in that play button and click on RUN

And regarding that error
Is workbook path passed to the argument or varivale mentioned in that read range activity

Cheers @fairymemay

1 Like

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