Skip to main content

Hi to all! This is my first post here. I’m new in this platform but I’m I have been working on other platforms such as UiPath and BluePrism for years.

 

I’m not sure is this a bug or that’s how it works because it doesn’t makes sense to me:

  1. I have PARENT bot and a CHILD bot.
  2. In CHILD bot I defined an output variable ‘out_childVar_str’ (output checked)
  3. I have mapped this variable with an appropriate variable in the PARENT bot (parentVar_str).
  1. In a Child bot I assign a value to a variable ‘out_childVar_str’.
  1. After that assign action, I simulate an error with a throw then bubble that error to a Parent bot
  2. NOW...my problem is that parent variable (parentVar_str) has not getting the value from the mapped Child bot variable (out_childVar_str)

 

When I go through the child bot without a simulated error, the parent variable gets populated with the value from the child bot variable as it should be.

But with the simulated error this just not working. Please help me with this one!

 

Thank you!

 

Welcome ​@dean.hubak to the Automation Anywhere family!

I think where you're getting hung up is in the Throw actions. If you use a Throw in a Try block, it simulates the error. If you use a Throw in the Catch block, it should terminate the Try/Catch, which is not what you want to do. 

If you remove the Throw in the Catch, it should be able to pass the value back to the parent. 


Thank you for your response ​@Aaron.Gleason

I understand that it works when there’s no Throw action within the Catch part...I have tried that.

But then, how to:

  1. Bubble up (rethrow) an exception from a Child bot to Parent with all the info about an error in child bot in it + my personal inputs (in case we need that kind of error message info in Parent...in 99% we need that) and
  1. at the same time transfer all the values from other output variables, that child bot has collected, to the Parent bot mapped variables?

My logic was:

  1. Catch the error in child bot
  2. Put error details (Child’s errorMessage, lineNumber) + info that I want in ‘errorDetailsVariable’.
  3. (Re)throw with all the info from the ‘errorDetailsVariable’
  4. Catch that error in Parent bot and process it…

 


@dean.hubak The Catch action allows you to assign error information to an “Error Message” string and an “Error Line Number” integer. Those values can be assigned to variables that can be marked as output.

Then, when flow returns to the parent, you can check if the “Error Line Number” value is greater than zero. If so, an error occurred. 

Here’s my parent bot:
 

I used your variable naming scheme for clarity

Here’s my child bot:

When I run the parent bot, it displays a message box with 123 in it.

I hope this clarifies things.


Thank you ​@Aaron.Gleason , thats one way to do that. I just want to follow best practices ;)


@dean.hubak These are best practices for Automation Anywhere. I’m a trainer here.  😉


@dean.hubak These are best practices for Automation Anywhere. I’m a trainer here.  😉

Ok...so you can explain my next question/observation regarding this issue 😉

Much thank you, ​@Aaron.Gleason 


This is my new version of the Child bot...as you see, I removed the throw action form the Catch part and put it in the Finally section

 

 

Still yet, my Child’s output variables are still blank in mapped parent var’s after Child is throwing that second error at the bottom.

 

 

 

I have also tried to move IF outside Finally section...still got the same results.

 


@dean.hubak I’m not sure why you’re using Throws outside of a Try, but that’s not best practice.

If you run your child bot directly, you’ll notice the automation will throw an error at step 12. Throws outside of a Try will cause the automation to stop prematurely and/or display an error. 


@Aaron.Gleason, thank you for your effort!

 

I understand that...if you are looking only the Child bot...but there is also a Parent bot :)

 I’m just trying to figure out the easiest way to collect the information what happened in a Child bot (errorLineNumber, errorMessage) and add my personal comment into that exception and pass it to the Parent bot.

 

Thats why I’m using an ‘Assign: String’ action (into errorMessage variable) in line 9 of a Child bot - to collect all the information about the error in the Child bot and customize my error message with more personalized detail. It would look like this:

[TEST - CHILD, 7]: Error details

 

Then I would use that personalized errorMessage variable mentioned above in that Throw (line 12) to rethrow/pass it to a Parent bot in one step so it can be handled there.

 

 

In Parent bot, I would use a log action instead of Message box (which is there only for reading the error message while I’m testing it) so I can log an error in a Parent bot that would look something like this:

timeStamp; ERROR; [TEST - Parent, 2] [TEST - Child, 7] - Error text

 

In that way I would know the exact place and reason for which Child bot failed, and also where exact the Parent bot caught the error (ParentErrorLineNumber)...or in other words, at what line Child bot was called (because Parent bot would be a sort of Main Task bot which can be stacked with many lines of code)

I just trying to output as less number of Child’s output variables (such as lineNumber) and don’t deal with them after the process is continued in Parent bot (as in your example).

 

I hope that is clear enough what I’m trying to say :)

 

But...lets get to the the main problem...if i Rethrow the error message in Child bot (line 12), even that Throw action is outside the Catch part (as you suggested it), other output variables of a Child bot are not go to the mapped Parent variables. I wonder why is that so?


Hey ​@dean.hubak, I guess I wasn't as clear as I should have been. I created two output variables: out_ErrorMessage_str and out_ErrorLineNumber_num (trying to replicate your naming scheme) and assigning them in the Catch action itself. That will report what error happened in the child to the parent. All the parent has to do is look at the two variables assigned by the Catch action. 

 

The Throw action (if you even need one) should only be used in the Try. Not the Catch. Not the Finally. Those will cause unexpected problems. 

 

You can replace the Throw in the Try with something like a CSV: Close to close an unopened file (which will obviously cause an error). I hope that makes sense.


Thank you ​@Aaron.Gleason for your effort!

As I said before...I’m new in this platform but I have an experience in other platforms.

I find it very unpractical that if error occur in Child bot that has NO Try block, that the information collected during it’s execution and before an error (out_childVar) don’t get transferred to a mapped Parent variable (parentVar_str) when the Parent bot catches the Child error.

 

Same goes in case when Child error has not handled properly through it’s own Try block.

 

But thats how it is, obviously...

 

Than you, ​@Aaron.Gleason once again for every second of your effort


@dean.hubak Every platform and programming language has its quirks. This is one of ours. Another is that we can have a Try block without a Catch!

Please feel free to tag me for any other questions you may have. Enjoy your weekend!


@dean.hubak This does not seem intended, try recreating fresh parent child file and their mapping.

Other option is to pass dictionary as input and update the key-value - they are passed by reference.


@dean.hubak This does not seem intended, try recreating fresh parent child file and their mapping.

Other option is to pass dictionary as input and update the key-value - they are passed by reference.

Hi ​@Bot Dev,

I also thought that this is some kind of a bug. But as ​@Aaron.Gleason said..thats one of the quirks of AA. If you want to pass Child variable to a mapped Parent variable (in case of Child error), you must properly handle that error in Child bot or it’s output variables will not be passed to a mapped Parent. Strange and at the same time very unpractical, as you can see.

 

Regarding your proposition to use a a Parent dictionary and pass it to a Child...what is the purpose to pass a dictionary variable from Parent to Child, collect the Child values and pass them into Child’s dictionary when it is not get passed back to Parent in case of Child error if its not properly handled in it’s own Try/Catch block…

 

So...the only way to pass output variables from Child to Parent (when error in Child occur) is to properly handle the Child’s error in it’s own Try/Catch block:

 

 


@dean.hubak 

Yes, it seems we need to put each task in try catch to ensure, the output mapping code runs internally😶.

I always used Try-catch-finally in all my tasks, log error details in catch, and throw from finally if error has occurred and let parent handle it(or it gets rethrown again in similar fashion.) I remember getting error thrown and output variables getting mapped as well.

 

Without using try catch in child: you can still pass value, by using reference variable types like dictionary. This would remove the need of output mapping step which internally does not run in case of errors.

Child:

 

Parent:

 


calling subtask from Main task

Throwing business exception

Run from Main task - output
 

 


calling subtask from Main task

Throwing business exception

Run from Main task - output
 

 

 

Thank you ​@Pravin 3017 . Thats the only way to pass Child output variables (sampleString, errorMessage). We came to this conclusion already before. Only with a help of Try/Catch block in Child, it’s output variables are passed to a mapped Parent’s variables.

 

If we want to handle Child’s error message from Parent:

  1. That error message must be caught in Child’s Catch block,
  2. Then passed (as an output variable, ex. out_childErrorMessage) to a mapped Parent variable
  3. ReThrow it to the Parent’s Catch block (as shown in my previous post - image below) and handle it from a Parent.

    For all other Child’s output variables, also, they will be passed to Parent only if there’s a Try/Catch block in the Child bot.


Hi ​@dean.hubak ,

 

Instead of throwing the error immediately after assigning the value, consider the following best practice/workaround:

Use a Dictionary or Status Variable to Capture Output Before Error Propagation

  1. Create a Dictionary Variable in the Child Bot:

    • Store all output values (e.g., out_childVar_str) inside the dictionary.
    • Include a status key like "errorOccurred": false.
  2. Assign Values Before Throwing Error:

    • Populate the dictionary with all necessary values.
    • Set "errorOccurred": true if an error condition is met.
  3. Return the Dictionary as Output:

    • Mark the dictionary as an output variable.
    • Do not throw the error directly. Instead, return the dictionary and let the Parent Bot inspect the "errorOccurred" flag.
  4. Handle Error in Parent Bot:

    • After receiving the dictionary, check the "errorOccurred" flag.
    • If true, log or handle the error accordingly (e.g., throw a custom error from the Parent Bot).

Hi ​@dean.hubak ,

 

Instead of throwing the error immediately after assigning the value, consider the following best practice/workaround:

Use a Dictionary or Status Variable to Capture Output Before Error Propagation

  1. Create a Dictionary Variable in the Child Bot:

    • Store all output values (e.g., out_childVar_str) inside the dictionary.
    • Include a status key like "errorOccurred": false.
  2. Assign Values Before Throwing Error:

    • Populate the dictionary with all necessary values.
    • Set "errorOccurred": true if an error condition is met.
  3. Return the Dictionary as Output:

    • Mark the dictionary as an output variable.
    • Do not throw the error directly. Instead, return the dictionary and let the Parent Bot inspect the "errorOccurred" flag.
  4. Handle Error in Parent Bot:

    • After receiving the dictionary, check the "errorOccurred" flag.
    • If true, log or handle the error accordingly (e.g., throw a custom error from the Parent Bot).

@Padmakumar

Thank you for the proposed solution. It is similar to the one suggested above by ​@Aaron.Gleason. – to catch the error in the child bot, handle it properly (put it in out_errorMessage variable), and then exit from the child bot to the parent bot in the regular way. The only deference is that he uses out_errorLineNumber (child’s output variable) as a signal in Parent that an error ocurred in Child and then throws an error in Parent with the text from mapped errorMessage variable.

Regarding the dictionary output variable...I dont want to have all the variables in dictionary. I would like to have an option to see the values of each variable in process and not to go to dictionary every time to see what values I picked up. Also, that dictionary would always be blank until It get’s populated with variables and I would not know which variable I’m using in the default list of variables on the left side of the Control Room so I always must go through code and inspect what’s happening...so that dictionary solution is definitely not as I expected to be.

 

Again..it is really frustrating that this kind of a simple thing must even been discussed on this forum and searching for all sorts of workarounds when the feature asked can not be more basic.

Once again...thank you all for your support.

 


Honestly, it is basic. If you let go of pre-conceived notions of how you think error handling should be, and allow yourself to simplify your thought process.

For example, we can use a Try with no Catch, Throw, or Finally. Most languages don't allow this. We do and it's quite useful for optional steps. 

Open your mind! 😏 


Honestly, it is basic. If you let go of pre-conceived notions of how you think error handling should be, and allow yourself to simplify your thought process.

For example, we can use a Try with no Catch, Throw, or Finally. Most languages don't allow this. We do and it's quite useful for optional steps. 

Open your mind! 😏 

@Aaron.Gleason 

I guess I have to :) But explain this ‘Try with no Catch’ thing...what is the purpose of Try without Catch? I guess it is doing the same thing as an empty catch block...annul the error so the process can go further?

 

Thank you


Exactly! A Try without a Catch lets you just move on as if the error never happened. No need to make your code more complex than it needs to be. 

Just experiment with Debug more or Message Boxes in your code so you can inspect the variables throughout the error handling process.