Table of Contents

Struct Result

Namespace
LfrlAnvil
Assembly
LfrlAnvil.Core.dll

Represents a result of an operation.

public readonly struct Result
Inherited Members
Extension Methods

Properties

Exception

Optional Exception associated with this result.

public Exception? Exception { get; }

Property Value

Exception

Valid

Returns a valid Result instance.

public static Result Valid { get; }

Property Value

Result

Methods

Create<T>(T?)

Creates a Result<T> with optional value.

[Pure]
public static Result<T> Create<T>(T? value = default)

Parameters

value T

Optional value associated with the result.

Returns

Result<T>

New Result<T> instance.

Type Parameters

T

Type of an optional value.

Error(Exception)

Creates a Result with exception.

[Pure]
public static Result Error(Exception exception)

Parameters

exception Exception

Exception associated with the result.

Returns

Result

New Result instance.

Error<T>(Exception, T?)

Creates a Result<T> with exception and optional value.

[Pure]
public static Result<T> Error<T>(Exception exception, T? value = default)

Parameters

exception Exception

Exception associated with the result.

value T

Optional value associated with the result.

Returns

Result<T>

New Result<T> instance.

Type Parameters

T

Type of an optional value.

ThrowIfError()

Rethrows the Exception, if it isn't null, otherwise does nothing.

public void ThrowIfError()

ToString()

Returns the fully qualified type name of this instance.

[Pure]
public override string ToString()

Returns

string

The fully qualified type name.