Class Reason

Namespace
REslava.Result
Assembly
REslava.Result.dll

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

message string

Human-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

message string

Human-readable description. Must not be null or whitespace.

tags ImmutableDictionary<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

string

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

ImmutableDictionary<string, object>

Methods

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.