Skip to content

Return detailed failure information from domain event handler responses #1938

Closed

Description

@StuartFerguson

Goal

Return useful diagnostic details when one or more domain-event handlers fail instead of returning a bare HTTP 500.

Proposed change

  • Update TransactionProcessor/Controllers/DomainEventController.cs to retain each handler alongside its task.
  • Await handler execution asynchronously with Task.WhenAll.
  • Aggregate all failed handler results, including the handler name and failure message.
  • Capture handler exceptions as failure entries.
  • Return an RFC 7807 ProblemDetails response with:
    • title: One or more event handlers failed
    • status: 500
    • eventId
    • eventType
    • failures, containing handler and error for each failure.
  • Preserve the existing successful 200 OK behavior.
  • Add focused controller coverage for the response shape and multiple failures.

Example response

{
  "title": "One or more event handlers failed",
  "status": 500,
  "eventId": "fe57bd2b-3ccb-4d10-a2f7-7435237d4d19",
  "eventType": "ProductDetailsAddedToTransactionEvent",
  "failures": [
    {
      "handler": "ReadModelDomainEventHandler",
      "error": "Transaction not found with Id ..."
    }
  ]
}

Acceptance criteria

  • Every failed handler is represented in the response.
  • Each failure identifies the handler and its error message.
  • Thrown handler exceptions are captured consistently.
  • No stack traces or sensitive implementation details are exposed unintentionally.
  • Existing success and retry/parking behavior remains compatible.
  • Relevant tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions