Skip to content

Add ExceptionPropertiesSample demonstrating IExceptionPropertiesProvi…#560

Merged
torosent merged 11 commits intomainfrom
add-exception-properties-sample
Dec 15, 2025
Merged

Add ExceptionPropertiesSample demonstrating IExceptionPropertiesProvi…#560
torosent merged 11 commits intomainfrom
add-exception-properties-sample

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

@YunchuWang YunchuWang commented Dec 13, 2025

This pull request adds a new sample, ExceptionPropertiesSample, to demonstrate how to enrich TaskFailureDetails with custom exception properties using the IExceptionPropertiesProvider interface 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:

  • Added new sample project ExceptionPropertiesSample with 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:

  • Implemented BusinessValidationException with additional properties (ErrorCode, StatusCode, Metadata) for richer error diagnostics.
  • Added CustomExceptionPropertiesProvider that implements IExceptionPropertiesProvider to extract custom properties from specific exception types and include them in orchestration failure details.

Sample orchestration and activity:

  • Created ValidationOrchestration and ValidateInputActivity to simulate input validation and throw custom exceptions with enriched properties on failure.

Sample usage and demonstration:

  • Added Program.cs to 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:

  • Included a detailed README.md explaining 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)

  • No
  • [] Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): vscode
  • AI-assisted areas/files: all
  • What you changed after AI output: asked it to make sample connect to dts instead of local sidecar

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Copilot AI review requested due to automatic review settings December 13, 2025 20:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

YunchuWang and others added 2 commits December 13, 2025 12:46
…ariable'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 20:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings December 13, 2025 21:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants