Class ErrorsOf<T1, T2>

Namespace
REslava.Result.AdvancedPatterns
Assembly
REslava.Result.dll

A type-safe error union of two possible error types. Inherits shared dispatch from OneOfBase<T1, T2> and implements IError by delegating Message and Tags to the active case.

public sealed class ErrorsOf<T1, T2> : OneOfBase<T1, T2>, IOneOf<T1, T2>, IError, IReason, IEquatable<ErrorsOf<T1, T2>> where T1 : IError where T2 : IError

Type Parameters

T1

The first error type. Must implement IError.

T2

The second error type. Must implement IError.

Inheritance
OneOfBase<T1, T2>
ErrorsOf<T1, T2>
Implements
IOneOf<T1, T2>
Inherited Members
Extension Methods

Remarks

Use ErrorsOf<T1, T2> as the TError in Result<TValue, TError> to accumulate the union of error types across a pipeline built with Bind.

Properties

Message

Gets the human-readable description of this reason.

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

Equals(ErrorsOf<T1, T2>?)

Determines equality between two ErrorsOf instances.

public bool Equals(ErrorsOf<T1, T2>? other)

Parameters

other ErrorsOf<T1, T2>

Returns

bool

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromT1(T1)

Creates an ErrorsOf containing a T1 error.

public static ErrorsOf<T1, T2> FromT1(T1 value)

Parameters

value T1

Returns

ErrorsOf<T1, T2>

FromT2(T2)

Creates an ErrorsOf containing a T2 error.

public static ErrorsOf<T1, T2> FromT2(T2 value)

Parameters

value T2

Returns

ErrorsOf<T1, T2>

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Operators

operator ==(ErrorsOf<T1, T2>?, ErrorsOf<T1, T2>?)

Equality operator.

public static bool operator ==(ErrorsOf<T1, T2>? left, ErrorsOf<T1, T2>? right)

Parameters

left ErrorsOf<T1, T2>
right ErrorsOf<T1, T2>

Returns

bool

implicit operator ErrorsOf<T1, T2>(T1)

Implicit conversion from T1 to ErrorsOf<T1, T2>.

public static implicit operator ErrorsOf<T1, T2>(T1 value)

Parameters

value T1

Returns

ErrorsOf<T1, T2>

implicit operator ErrorsOf<T1, T2>(T2)

Implicit conversion from T2 to ErrorsOf<T1, T2>.

public static implicit operator ErrorsOf<T1, T2>(T2 value)

Parameters

value T2

Returns

ErrorsOf<T1, T2>

operator !=(ErrorsOf<T1, T2>?, ErrorsOf<T1, T2>?)

Inequality operator.

public static bool operator !=(ErrorsOf<T1, T2>? left, ErrorsOf<T1, T2>? right)

Parameters

left ErrorsOf<T1, T2>
right ErrorsOf<T1, T2>

Returns

bool