Add ExceptionPropertiesSample demonstrating IExceptionPropertiesProvi…#560
Merged
Add ExceptionPropertiesSample demonstrating IExceptionPropertiesProvi…#560
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new sample demonstrating the usage of IExceptionPropertiesProvider to enrich TaskFailureDetails with custom exception properties. The sample shows how to create custom exceptions with additional diagnostic information and how to configure the Durable Task framework to automatically extract and include these properties in failure details.
Key Changes
- Adds a complete standalone sample showing IExceptionPropertiesProvider usage
- Demonstrates custom business validation exceptions with error codes, status codes, and metadata
- Shows how to register and use the provider with the Durable Task worker
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/ExceptionPropertiesSample/Tasks.cs | Defines orchestration and activity that demonstrate throwing custom exceptions |
| samples/ExceptionPropertiesSample/README.md | Comprehensive documentation explaining the sample's purpose, structure, and usage |
| samples/ExceptionPropertiesSample/Program.cs | Main entry point that configures the worker, registers the provider, and runs test cases |
| samples/ExceptionPropertiesSample/ExceptionPropertiesSample.csproj | Project configuration following standard sample patterns |
| samples/ExceptionPropertiesSample/CustomExceptions.cs | Custom BusinessValidationException with additional diagnostic properties |
| samples/ExceptionPropertiesSample/CustomExceptionPropertiesProvider.cs | Implementation of IExceptionPropertiesProvider that extracts custom properties from exceptions |
Comments suppressed due to low confidence (1)
samples/ExceptionPropertiesSample/Tasks.cs:22
- This assignment to ex is useless, since its value is never read.
catch (TaskFailedException ex)
…ariable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…microsoft/durabletask-dotnet into add-exception-properties-sample
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
torosent
approved these changes
Dec 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a new sample,
ExceptionPropertiesSample, to demonstrate how to enrichTaskFailureDetailswith custom exception properties using theIExceptionPropertiesProviderinterface in Durable Task. The sample includes custom exception types, a provider for extracting properties, orchestration and activity implementations, and documentation.New Exception Properties Sample
Sample project and solution integration:
ExceptionPropertiesSamplewith supporting files, and integrated it into the solution (Microsoft.DurableTask.sln). This includes build configuration and project references for both local and DTS scenarios. [1] [2] [3] [4]Custom exception enrichment:
BusinessValidationExceptionwith additional properties (ErrorCode,StatusCode,Metadata) for richer error diagnostics.CustomExceptionPropertiesProviderthat implementsIExceptionPropertiesProviderto extract custom properties from specific exception types and include them in orchestration failure details.Sample orchestration and activity:
ValidationOrchestrationandValidateInputActivityto simulate input validation and throw custom exceptions with enriched properties on failure.Sample usage and demonstration:
Program.csto set up the worker, register the custom exception properties provider, and run test cases to show how enriched failure details are retrieved and displayed.Documentation:
README.mdexplaining the sample's purpose, setup, usage, and expected output, with code snippets and notes for users.AI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):