Best practices of error handling

Hello,

I would like to know what approaches you use to handle unexpected errors.

For our bots we use the following approach:
1. there are several tasks for one bot. Each task does a part of a process
2. also, we have a task "main". Here we implement the global logic of a process and we use a command "Run Task" where it is needed
3. to prevent unexpected errors (ex. internet connection is bad => the page cannot be loaded => AA does not find an object => error) we put the body of a task in "Error Handling". If there is this type of errors we stop task and pass a variable unexpectedError = True.
4. in the "main" task after each "Run Task" we put "If" and check the condition unexpectedError==True. If it is true, we stop the task main, so we stop the bot.

For example:
subtask1.atmx:
Begin Error Handling
bot actions
End Error Handling

main.atmx:
bot actions
Run Task "subtask1.atmx"
if(unexpectedError == True){
Stop Task
}
bot actions

With this approach our "main" task is very big and it is not good. So I am interested how you handle unexpected errors in your projects. Thank you for your answers. If you have links for best practices of this subject, I will appreciate it a lot.

Comments

  • What I am doing, is calling subtasks by passing lineno and errdesc parameters and catching them in main task. and refactoring the main task to keep it as small as possible.

    For example:
    subtask1.atmx:
    Begin Error Handling
    bot actions
    End Error Handling
    variable operation set lineno -> lineno
    variable operation set errdesc -> errdescription

    subtask2.atmx:
    Begin Error Handling
    bot actions
    End Error Handling
    variable operation set lineno -> lineno
    variable operation set errdesc -> errdescription

    main.atmx:
    bot actions
    Run Task "subtask1.atmx", line no, errdesc
    if(lineno== 0){
    variable operation set lineno -> lineno
    variable operation set errdesc -> errdescription
    Stop Task
    }

    Run Task "subtask2.atmx" lineno, errdesc
    if(lineno== 0){
    variable operation set lineno -> lineno
    variable operation set errdesc -> errdescription
    Stop Task
    }

    this way its error handling is consistent and I can control at what level I need to handle the error.

Sign In or Register to comment.