Out argument value after an exception

Hi ,
i am aware that this topic has been discussed multiple times , here. infact i followed one of the method suggested by @loginerror. but still i have not got the desired result.
scenario :

  • i have many sequences inside process.xaml in a flow chart.
  • at the begging of the sequence an out variable (out argument of process.xaml) is assigned.
    the idea is the update the value at the beginning of the every seq and when ever an exception occurs (system/ business) that particular stage can be carefully captured. and can be informed to the business.

now problem :
as we all know during exception for some reason the assigned value of the out argument is not reflecting. so i had put these sequences under a try catch. and in catch am setting the “out argument” and rethrowing the exception.
why rethrow ? , because only if i catch that exception with the try catch of process.xaml , i can do some activity which is common to all the sequences under “process.xaml”
now , am not getting the out argument again ! why ?? is it because of the rethrow , if so then what is the solution !?

4 Likes

Hi @Seetharaman_K

Actually, there is a simpler workaround. Please give this answer a read:

2 Likes

thank you for the reply first of all. so instead of even surrounding the sequence with try catch , you a re suggesting to pass the argument as a an array ? say eg , array of string which is of size 1. thats all.

2 Likes

Precisely. It should do the trick.

2 Likes

actually i did what you suggested but it is not showing the result.
what i did ?
changed the argument type of the out argument to string array. in process xaml.
inside process.xaml first sequnce , first statement it stores the valued of the out arguement in the as the first element of the array. and then testing with a throw . something like below
image
i tested whether value is toring fine with the msg box it works.
now after throw it comes out of process.xaml. and process.xaml argument structure is something like this.

exception stage is the array variable created with scope as “general business”
now in the catch section which handles the above exception am trying to print exceptionstage(0). but it is printing blank value.
why blank value ? because i had initialized the variable “exceptionstage” with {“”}. and it is supposed to get replaced with the value from the out argument.
why this is happening ?
as you had explained before , i am dealing with array data type only here!

3 Likes

infact while assigning the value to the array inside the sequence under process.xaml ,
i had put like as follows . ie assining on the specific index. that is what also suggested in the post quoted by you. but still em getting empty string.
image

3 Likes

I tried to reproduce a working version.

Could you give this project a run and see if it produces the expected output like this one:
image

PushArgumentOnException.zip (3.2 KB)

5 Likes

let me try and get back in few mins

2 Likes


what happened ? why this error

2 Likes

Could you unpack entire project to the separate folder and open it from the project.json file?
This way Studio will download the correct dependencies for the project.

2 Likes

when i tried open via json , it says project error detecting project version hence i deleted the project.json and tried to open the main file.

2 Likes

Got it, it’s an older version of Studio. In that case, this activity is the Invoke Workflow one:
image

With these parameters:

3 Likes

ok in short , it worked !! and thanks for it.
but the story is ,

  1. i couldn’t drag and drop the seq after deleting the “missing activity”.
    2.so i created a new project replicated ur code.
    3.only difference between ur code and the one i pasted as iamge is

in this screen shot i had initialised the array with “new” . which in your case is not there. so i had taken it out. and it worked!!

so it worked anyway at the end but why that initialization was a problem ! ?

2 Likes

also one more change
and also i had initialised the local variable with a “New” . this is the variable which will get the value from the “out argument”.

2 Likes

If I understand @andrzej.kniola explanation from here:

We can’t initialize the array inside the second workflow because the reference will no longer point ‘outside’ of the workflow (which is the case if you initialize it before entering that second workflow).

At least that’s how I understand it :sweat_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.