RPA | Error Handling Command | Automation Anywhere - Part-14
Error Handling Command | Before we discuss about Error Handling command let us discuss about what is an "Error" and why do error occur in our code.
Errors are the mistakes or faults in the program that causes our program to behave unexpectedly.
There are three types of errors we can have which are as mentioned below:
1) Logical Errors - Logical errors are those errors which will cause the program to misbehave which will result in the wrong output.
2) Syntax Errors - Syntax errors are those errors which result from incorrect programming syntax i.e. the programmers write the incorrect syntax in the code i.e. when these types of errors occur. These types of errors are also known as compilation errors.
3) RunTime Errors - RunTime errors are those errors which are detected during the execution of the program. These errors do occur when the user enters an invalid data or data which is not correct.
To prevent these type of errors and to let our code run smoothly we have the Error Handling command to handle these types of errors.
In Automation Anywhere we have the command named as Error Handling command and to use this command we require or need the Error Handler package to use this command in our code.
The Error Handler package contains actions that enables us to easily handle exceptions that a bot encounters and transfers control to the other actions within that bot. It also provides actions that enables us to separate actions that we want to use to perform a task from the actions that we want to use to handle an exception.
The actions that are provided under Error Handling command are as follows:-
1) Try - Try command enables us to list the "sequence of actions" which might encounter an error. If the bot encounters or finds an error from running the actions which are provided under the try command it attempts to catch that error using the Catch command which will be explained in the next point.
2) Catch - Catch command enables us to specify an alternate sequence of actions to run if the bot encounters an error while running any of the actions in the Try section. We can assign the exception message or the line number to a variable and then insert the variable to Log to file, Message Box and also can be used in Email->Send Option.
3) Finally - Finally command enables us to specify actions which we want to run regardless of the bot encounters an error or not. The Finally statement enables us to execute code after try and catch regardless of whether an exception occurs or not in the bot.
4) Throw - Throw statement displays a custom message if the bot encounters an error. We can specify the message we want to show in the "Please enter Exception message" field.
Now we will take a look at the code snippet of how to use Error Handling command.
In case if you have any queries related to Error Handling command then do please feel free to reach out to me with your queries and I will be more than happy to resolve your queries.
Good job!
ReplyDeleteThanks for sharing such a good and informative content to all of us
ReplyDeleteMulesoft Online Course
Online Mulesoft Training
This is really informative blog, I have to thank for your efforts. Waiting for more post like this.
ReplyDeleteAutomation Training Institute in Chennai
Automation Anywhere course in Chennai
Automation Anywhere course
Online Openspan Training