I am raising an exception from my python Script and would like to get it catched and logged in UiPath. I have use Try-Catch block around my invoke python method.
On, the exception messages which gets Catched is “One or more error occured”.
In Debug mode if I check i found remote exception → System Aggregate Exception → System IO Exception → System Invalid Operation Exception → Then the actual exception message which I am raising from python script.
Instead of “One or more errors occurred” I would like to catch the exception message which I raised from python script
I tried different type of exception in catch block such as system.Exception, system.AggregateException, system.RemoteException, system.SystemException. But wasn’t able to achieve the results.
would it be possible for you to tweak your script that instead of raising an exception you return the exception statement. I assume you script has a function so in the excepetion block/ if condition you are rasing an exception use a return statement
If your python script throws any exception, UiPath Invoke Python Method will throw exception “Pipe is broken”. It means, the communication channel between UiPath and the Python process has been disrupted, likely due to an unhandled exception in the Python script. When the Python script throws an exception, the Python process might terminate abruptly, causing the pipe to break and leading to the System.IO.IOException in UiPath.
To handle this scenario, you need to ensure that exceptions from the Python script are properly captured and communicated back to UiPath.
You will have to customize your script to catch the exception and assign it to function to return to UiPath.
Here is a sample workflow I have built to explain this.
Python Script:
def run_script():
try:
# Thowing exception
raise Exception("Sample Exception, This is exception from python script")
except Exception as e:
result = str(e)
return result