Make a Bot task to exit abnolmally

Hi,

I have a recording that logs in a web site, and I implemented exception handling in order to be able to:

  • log the event of login failure
  • do some other actions

But in that case the bot task reports status is completed successfully (100%). Is it possible to set the status of a bot task to failed? (like we would do in any programming language using i.e. exit 1 )

Hello

The equivalent exit functionality can be achieved using the “Try Catch” functionality which is known as “Exception Handling” in WorkFusion.

Test for something that indicates success then have a catch that (eg) writes an error code to a log file. Nest these if you have more than one error exit condition.

Yes, but this is not my question.
I’m asking how to make the bot task (recording) to exit abnormally after the execution of the “if an exception occurred” block.

Something like this:
image

Hi @adimitriou, if the bot executes either of the action groups (Try to complete and If an exception occurred) it considers the task successful, and you cannot change the status. That is the purposes of the Exception Handling action - the execution is always successful, and the process doesn’t fail.

The way I can think of right now is to split your bot task into 2:
1st - the Login part (Try to complete part)
2nd - failed login (the If an exception occurred part)

and add a Rule after the 1st bot task to go to the end after a successful login and to go to 2nd bot task after an unsuccessful one.

Then you’ll see if bot task 2 was played during the business process execution.
Not sure though that it will make much difference.

And my point was to use a log file to write exit conditions in each of the branches so that you could see where it actually terminated:

“Try to Complete”
…Write into log file “I did this in the try to complete branch”

“If an exception occurred”
…Write into log file " I was in the exception branch and terminated there with Error Code 1"

If you are using the status elsewhere then write code to collect this structured text from the log and make subsequent decisions based on what it finds. You can use nesting to get as much granularity as you want with the exception codes and then reference the log file to see what actually happened without needing to examine the execution code in recorder.

It’s not good practice to ‘want’ an application to crash in an uncontrolled way whether it gives an error notification or not. Better to have it quit in an expected manner but find the reason from a log.

1 Like

@ashapkina
Thank you but it’s not going to solve my case.
What I need is to have the error logged and also be able to notify user that the execution has issues, in Control Center.
I know that there are a lot of workarounds for that (email, alert using monitoring tools, etc.) but I wanted to use only RPA because that way user can solve the error and restart BP from the same step of the flow. Is that feature available?

And one more question. I did a test with your solution and firefox is closing after the first bot task is completed.
Can I open firefox with the open website step and left it open for use in next bot tasks?

@Bonnero
Thank you for your help but unfortunately this is not the case.

You cannot leave a website open after bot task execution as the system has to be returned to the state it was in before the execution.
I thought the second part didn’t have actions on this webpage, so I suggested this approach.

There is no such feature available. In this case you can either use email notification (or other applications) or you can not use exception handling, in this case the process’s status will be “failed” in Control Tower. User will be able to access error log of the process and repair the process.

Thank you @ashapkina

@ashapkina Hi, is there a way to exit bot task in case there is no data returned by sql plugin? The business case has below steps.

  1. Extract qualifying data from db with plugin ( want to exit right here if there is no data returned.)
  2. Write data to excel file.
  3. Read data one by one in loop from excel file (Step 2) and process via Web site.
    I have the whole thing working in one bot task but wants to quit gracefully in case there is no data fetched.
    Best–

Just use a simple while loop around all of your data?

eg "while - > there is data
do stuff
end while
exit

Then if there is no data the bot will go directly to exit.

1 Like

@Bonnero, thanks for the response and clue. it would work. My issue with this is the web piece of script already has so many loops for parsing tables etc. So from clean code perspective/debugging it seems messy. But it works in case there is no other way.

Best–