FailOr 1.1.0
dotnet add package FailOr --version 1.1.0
NuGet\Install-Package FailOr -Version 1.1.0
<PackageReference Include="FailOr" Version="1.1.0" />
<PackageVersion Include="FailOr" Version="1.1.0" />
<PackageReference Include="FailOr" />
paket add FailOr --version 1.1.0
#r "nuget: FailOr, 1.1.0"
#:package FailOr@1.1.0
#addin nuget:?package=FailOr&version=1.1.0
#tool nuget:?package=FailOr&version=1.1.0
FailOr
FailOr is the core package for explicit success-and-failure flows in .NET. It gives you a small result type, a failure union, and composable helpers for mapping, matching, chaining, and aggregation.
Install
dotnet add package FailOr
Core Surface
FailOr<T>represents either a success value or one-or-more failures.Failuresis the abstract failure union carried by failed results.Failureis the public factory surface forFailures.General,Failures.Validation, andFailures.Exceptional.- Chaining and observation helpers include
Then,ThenAsync,ThenEnsure,FailWhen,ThenDo,IfSuccess,IfFail,Match,MatchFirst,Try,Zip, andCombine.
Quick Start
Create success and failure results:
using FailOr;
var success = FailOr.Success(42);
var failure = FailOr.Fail<int>(Failure.General("Input was invalid."));
if (success.IsSuccess)
{
Console.WriteLine(success.UnsafeUnwrap());
}
if (failure.IsFailure)
{
Console.WriteLine(failure.Failures[0].Details);
}
Chain success values:
using FailOr;
var result = FailOr.Success(10)
.Then(value => value + 5)
.ThenEnsure(value =>
value >= 0
? FailOr.Success(true)
: FailOr.Fail<bool>(Failure.General("Value must be non-negative.")))
.Then(value => value * 2);
Handle both outcomes with Match:
using FailOr;
var message = FailOr.Fail<int>(Failure.General("The value could not be produced."))
.Match(
success: value => $"Value: {value}",
failure: failures => failures[0].Details);
Convert thrown exceptions into failures with Try:
using FailOr;
var parsed = FailOr.Success("42")
.Try(value => int.Parse(value));
Related Package
Use FailOr.Validations when you want typed, property-selector based validation helpers that build on top of the core package:
dotnet add package FailOr.Validations
Documentation
- Repository overview: FailOr root README
- Core API reference: docs/api-reference.md
- Companion validations package: src/FailOr.Validations/README.md
License
Licensed under the MIT License. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FailOr:
| Package | Downloads |
|---|---|
|
FailOr.Validations
Typed property-based validation helpers for FailOr with selector normalization and transform pipelines. |
GitHub repositories
This package is not used by any popular GitHub repositories.