Skip to content

Commit 6598001

Browse files
authored
Create TestErrorHandling.xaml
1 parent af0aafe commit 6598001

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-16"?>
2+
<Workflow xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:s="clr-namespace:System;assembly=mscorlib"
5+
xmlns:ui="http://schemas.uipath.com/workflow/activities"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
mc:Ignorable="d"
9+
x:Class="TestErrorHandling"
10+
DisplayName="Test Error Handling">
11+
<Sequence DisplayName="Error Handling Test Sequence">
12+
<Variable x:TypeArguments="s:String" Name="result" />
13+
14+
<TryCatch DisplayName="Try-Catch for Error Handling Test">
15+
<Try DisplayName="Perform Error Handling Test">
16+
<WriteLine DisplayName="Starting Error Handling Test" Text="Starting the error handling test." />
17+
18+
' Simulate an error during data extraction
19+
Throw New Exception("Simulated data extraction error.")
20+
21+
' If no error occurs, this part would run
22+
<Assign DisplayName="Simulate Data Processing" To="[result]" Value="Data Processed" />
23+
<WriteLine DisplayName="Data Processing" Text="[result]" />
24+
</Try>
25+
<Catch x:TypeArguments="s:Exception" DisplayName="Exception Handling">
26+
<Sequence>
27+
<WriteLine DisplayName="Log Exception" Text="[String.Format('Error: {0}', exception.Message)]" />
28+
<Assign DisplayName="Set Result to Error" To="[result]" Value="Error Occurred" />
29+
</Sequence>
30+
</Catch>
31+
</TryCatch>
32+
33+
<If DisplayName="Validate Error Handling">
34+
<If.Condition>
35+
<InArgument x:TypeArguments="s:Boolean">[result.Equals("Error Occurred")]</InArgument>
36+
</If.Condition>
37+
<Then>
38+
<WriteLine DisplayName="Test Passed" Text="Error handling test passed." />
39+
</Then>
40+
<Else>
41+
<WriteLine DisplayName="Test Failed" Text="Error handling test failed." />
42+
</Else>
43+
</If>
44+
</Sequence>
45+
</Workflow>

0 commit comments

Comments
 (0)