Class Reason
Abstract base class for all result reasons (errors and successes). Provides immutable Message and Tags storage with a consistent ToString() representation.
public abstract class Reason : IReason
- Inheritance
-
Reason
- Implements
- Derived
-
Reason<TReason>
- Inherited Members
- Extension Methods
Remarks
Prefer inheriting Reason<TReason> to get fluent CRTP builders
(WithMessage, WithTag, WithTags).
Constructors
Reason(string)
Initializes a new reason with the given message and empty tags.
protected Reason(string message)
Parameters
messagestringHuman-readable description. Must not be null or whitespace.
Reason(string, ImmutableDictionary<string, object>)
Initializes a new reason with the given message and pre-populated tags.
protected Reason(string message, ImmutableDictionary<string, object> tags)
Parameters
messagestringHuman-readable description. Must not be null or whitespace.
tagsImmutableDictionary<string, object>Initial metadata tags. Null is treated as an empty dictionary.
Properties
Message
Gets the human-readable description of this reason.
[Required]
public string Message { get; init; }
Property Value
Tags
Gets the structured metadata attached to this reason.
Keys are string labels; values are arbitrary objects (e.g. HTTP status codes, field names).
Use WithTag on any concrete reason to attach metadata fluently.
public ImmutableDictionary<string, object> Tags { get; init; }
Property Value
Methods
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.