Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Core Concepts — Result, Error, Maybe & Generic

L0StableNuGet: v3.0.0Local HEAD: v3.2.0AOT: Partial

Understanding the memory layout and state machine of Result, Result<TValue>, and Error ensures predictable behavior across synchronous pipelines and default-struct boundaries.

Type Package Purpose
Result EricksonLopez.Result Non-generic outcome (Success or Failure(Error)); implements IResultOutcome, IResultFactory<Result>
Result<TValue> EricksonLopez.Result Generic readonly struct holding TValue or Error
Result<TValue, TError> EricksonLopez.Result.Generic Custom strongly-typed error TError with .IsUninitialized and .ToResult(...)
Maybe<T> EricksonLopez.Result.Maybe Optional value wrapper convertible via Maybe<T>.From(entity).ToResult(error)

Error is a sealed partial class exposing semantic factories mapped to ErrorType and default ErrorSeverity:

  • Error.Validation(code, desc) → ErrorType.Validation
  • Error.NotFound(code, desc) / Error.NotFound<TId>(code, id) → ErrorType.NotFound
  • Error.Conflict(code, desc) → ErrorType.Conflict
  • Error.Unauthorized(code, desc) / Error.Forbidden(code, desc) → Unauthorized / Forbidden
  • Error.Domain(code, desc) / Error.Business(code, desc) → ErrorType.Domain
  • Error.Unavailable(code, desc) / Error.Infrastructure(code, desc) → transient infrastructure faults
  • Error.Failure(code, desc) / Error.Unexpected(code, desc) → general or critical failures
  • Error.Create(code, desc) → returns ErrorBuilder for custom metadata/inner errors

Because C# allows default(Result) and default(Result<TValue>) on structs, v3.0.0 enforces strict uninitialized semantics:

  • default(Result<TValue>).IsSuccess and default(Result<TValue>).IsFailure are both false (TryGetError returns false, ToString() returns "Uninitialized").
  • Result.Combine and Result.ValidateAll reject uninitialized inputs instead of silently treating default as success.
  • WellKnownErrors.UninitializedError surfaces the diagnostic error when uninitialized structs are unwrapped or converted (Result(in Result<TValue>)).