Skip to content

Fault: an optional Cause, kept for the log and never written to the problem #84

Closed

Description

@CaffeinatedCoder

A caught exception is lost on the way to a Fault<TFault>: Result.Catch makes the exception the whole error, and the MapError that turns it into the fault an endpoint answers drops it, so a log of the refusal cannot say what failed underneath (decision 52, the roadmap's 2.3.0 section).

Proposal

  • An optional Exception? Cause on Fault<TFault>, set through Fault.Of(reason, detail, cause) (and the constructor), carried through WithRule and the composed Fault<T1, T2> / Fault<T1, T2, T3>.
  • Equality stays the reason's, the detail's and the rule's: a fault with a cause equals the same fault without one.
  • In AspNetCore, FaultProblem<TFault>.Cause and IFaultFeature.Cause (a default member, so a host's own implementation still builds) carry it for the log and CustomizeProblemDetails. It is never written to the problem.
  • The docs show MapError(e => Fault.Of(reason, detail, e)) from a Result<T, Exception>.

Done when

  • The cause is kept by WithRule, the composed faults and ToHttpResult(), and no problem body names the exception (type or message).
  • Equality and hash code ignore it; ToString() prints as 2.2 did.
  • Core and AspNetCore READMEs show it as compiled samples; changelog entry.

Activity

  1. added this to the 2.3.0 milestone on Oct 28, 2026
  2. CaffeinatedCoder commented on Oct 28, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Done in PR #89, merged into release/2.3.0.

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

    area/option-resultOption, Result and their extensionsenhancementNew feature or requestpackage/aspnetcoreAffects CodoMetis.TypeKit.AspNetCorepackage/coreAffects CodoMetis.TypeKit

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions