Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PropertyGroup>
<MajorVersion>0</MajorVersion>
<MinorVersion>7</MinorVersion>
<PatchVersion>0</PatchVersion>
<PatchVersion>1</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<FileVersion>$(VersionPrefix).0</FileVersion>
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PropertyGroup>
<MajorVersion>2</MajorVersion>
<MinorVersion>6</MinorVersion>
<PatchVersion>0</PatchVersion>
<PatchVersion>1</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<FileVersion>$(VersionPrefix).0</FileVersion>
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->
Expand Down
2 changes: 1 addition & 1 deletion src/DurableTask.Core/DurableTask.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PropertyGroup>
<MajorVersion>3</MajorVersion>
<MinorVersion>5</MinorVersion>
<PatchVersion>0</PatchVersion>
<PatchVersion>1</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<FileVersion>$(VersionPrefix).0</FileVersion>
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->
Expand Down
2 changes: 1 addition & 1 deletion src/DurableTask.Core/TaskOrchestrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public void FailOrchestration(Exception failure, OrchestrationRuntimeState runti
{
if (this.ErrorPropagationMode == ErrorPropagationMode.UseFailureDetails)
{
failureDetails = new FailureDetails(failure);
failureDetails = new FailureDetails(failure, this.ExceptionPropertiesProvider.ExtractProperties(failure));
}
else
{
Expand Down
104 changes: 104 additions & 0 deletions test/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,71 @@ await this.worker
}
}

[TestMethod]
// Test that when a provider is set, properties of exception thrown by orchestration directly will be included
// if excception type is matched.
public async Task ExceptionPropertiesProvider_SimpleThrowExceptionOrchestration()
{
this.worker.ExceptionPropertiesProvider = new TestExceptionPropertiesProvider();
this.worker.ErrorPropagationMode = ErrorPropagationMode.UseFailureDetails;

try
{
await this.worker
.AddTaskOrchestrations(typeof(SimpleThrowExceptionOrchestration))
.StartAsync();

var instance = await this.client.CreateOrchestrationInstanceAsync(typeof(SimpleThrowExceptionOrchestration), "test-input");
var result = await this.client.WaitForOrchestrationAsync(instance, DefaultTimeout);

// Check that custom properties were extracted
Assert.AreEqual(OrchestrationStatus.Failed, result.OrchestrationStatus);
Assert.IsNotNull(result.FailureDetails);
Assert.IsNotNull(result.FailureDetails.Properties);

// Check the properties match the ArgumentOutOfRangeException.
Assert.AreEqual("count", result.FailureDetails.Properties["Name"]);
Assert.AreEqual("100", result.FailureDetails.Properties["Value"]);
}
finally
{
await this.worker.StopAsync();
}
}

[TestMethod]
// Test that when a provider is set, exception properties are included in failure details with propogation.
public async Task ExceptionPropertiesProvider_SubOrchestrationThrowExceptionOrchestration()
{
this.worker.ExceptionPropertiesProvider = new TestExceptionPropertiesProvider();
this.worker.ErrorPropagationMode = ErrorPropagationMode.UseFailureDetails;

try
{
await this.worker
.AddTaskOrchestrations(typeof(SubOrchestrationThrowExceptionOrchestration))
.AddTaskOrchestrations(typeof(ThrowArgumentOutofRangeExceptionASubOrchestration))
.AddTaskActivities(typeof(ThrowArgumentOutofRangeExceptionActivity))
.StartAsync();

var instance = await this.client.CreateOrchestrationInstanceAsync(typeof(SubOrchestrationThrowExceptionOrchestration), "test-input");
var result = await this.client.WaitForOrchestrationAsync(instance, DefaultTimeout);

// Check that custom properties were extracted
Assert.AreEqual(OrchestrationStatus.Failed, result.OrchestrationStatus);
Assert.IsNotNull(result.FailureDetails);
Assert.IsNotNull(result.FailureDetails.Properties);

// Check the properties match the ArgumentOutOfRangeException.
Assert.AreEqual("count", result.FailureDetails.Properties["Name"]);
Assert.AreEqual("100", result.FailureDetails.Properties["Value"]);
}
finally
{
await this.worker.StopAsync();
}
}

class ThrowCustomExceptionOrchestration : TaskOrchestration<string, string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
Expand All @@ -352,6 +417,40 @@ protected override string Execute(TaskContext context, string input)
}
}

class SimpleThrowExceptionOrchestration : TaskOrchestration<string, string>
{
public override Task<string> RunTask(OrchestrationContext context, string input)
{
throw new ArgumentOutOfRangeException("count", 100, "Count is not valid.");
}
}

class SubOrchestrationThrowExceptionOrchestration : TaskOrchestration<string, string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
{
await context.CreateSubOrchestrationInstance<string>(typeof(ThrowArgumentOutofRangeExceptionASubOrchestration), input);
return "This should never be reached";
}
}

class ThrowArgumentOutofRangeExceptionASubOrchestration : TaskOrchestration<string, string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
{
await context.ScheduleTask<string>(typeof(ThrowArgumentOutofRangeExceptionActivity), input);
return "This should never be reached";
}
}

class ThrowArgumentOutofRangeExceptionActivity : TaskActivity<string, string>
{
protected override string Execute(TaskContext context, string input)
{
throw new ArgumentOutOfRangeException("count", 100, "Count is not valid.");
}
}

class ThrowInvalidOperationExceptionOrchestration : TaskOrchestration<string, string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
Expand Down Expand Up @@ -409,6 +508,11 @@ class TestExceptionPropertiesProvider : IExceptionPropertiesProvider
{
return exception switch
{
ArgumentOutOfRangeException e => new Dictionary<string, object?>
{
["Name"] = e.ParamName ?? string.Empty,
["Value"] = e.ActualValue?.ToString() ?? string.Empty,
},
CustomBusinessException businessEx => new Dictionary<string, object?>
{
["ExceptionTypeName"] = nameof(CustomBusinessException),
Expand Down
Loading