Hey everyone,
I’ve got kind of a weird situation here… I was just playing with Error Handling to get a better feel for how it works and the best ways to go about handling issues/abnormalities in processes, but I’ve come across something pretty strange…
I have a Main workflow, it has two variables: keyTest (String) & dictTest (Dictionary<String,String>), they are initialized as follows:
keyTest = "NOTHING"
dictTest = new Dictionary(Of String, string) from {{"One", "ONE"}, {"Two", "TWO"}}
These two variables are passed into some invoked workflows as In/Out variables. For the sake of testing, I passed them down through 3 Workflows, which I called WF1
, WF1a
, and WF1ai
. In the third workflow WF1ai
I used an Assign
and Add to Dictionary
Activity to modify these variables that are passed in (again, as In/Out) as follows:
keyTest = "TEST KEY"
dictTest.Add("Three", "THREE")
Once these are added, I have the workflow attempt a Click
Activity on something that doesn’t exist and it then errors. EACH OF THE WORKFLOW PROCESSES ARE WITHIN A TRY/CATCH. In the catch, I rethrow the exception that is caught. When returning to the Main
Workflow, I assign the exception to a SystemError Exception variable and it prints the corresponding exception Message/Source with no issues. Following this, I have it simply log two values, the values I modified in WF1ai
:
Console.WriteLine(keyTest.ToString)
→ Returns “NOTHING”
Console.WriteLine(dictTest.Item("Three").ToString)
→ Returns “THREE”
Why does the Dictionary stay updated while the string does not? They are both modified in the exact same spot within the workflow and are clearly modified before the error is thrown and the try/catch cascades back to the Main
Workflow, but keyTest does not return the modified value, but that added Dictionary KeyValuePair remains and is returned when logged.
Rough Model Below:
Main{
keyTest = "NOTHING";
dictTest = new Dictionary(Of String, string) from {{"One", "ONE"}, {"Two", "TWO"}};
InvokeWorkflow(WF1, keyTest(In/Out), dictTest(In/Out));
WF1{
InvokeWorkflow(WF1a, keyTest(In/Out), dictTest(In/Out));
WF1a{
InvokeWorkflow(WF1ai, keyTest(In/Out), dictTest(In/Out));
WF1ai{
keyTest = "TEST"; //Edit keyTest to pass back after errors
dictTest = dictTest.Add("Three", "THREE"); //Edit dictTest to pass back after errors
Throw("FAKE ERROR");
}
}
}
Console.WriteLine(keyTest); //Prints "NOTHING"
Console.WriteLine(dictTest.Item("Three")); //Prints "THREE"
}