Feather.ErrorHandling 2.1.0

dotnet add package Feather.ErrorHandling --version 2.1.0
                    
NuGet\Install-Package Feather.ErrorHandling -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Feather.ErrorHandling" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Feather.ErrorHandling" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Feather.ErrorHandling" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Feather.ErrorHandling --version 2.1.0
                    
#r "nuget: Feather.ErrorHandling, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Feather.ErrorHandling@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Feather.ErrorHandling&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Feather.ErrorHandling&version=2.1.0
                    
Install as a Cake Tool

<img src="https://github.com/FeatherTools/.github/blob/main/profile/feather-logo-200.png" alt="FeatherTools Logo" width="100" height="100"> Error-Handling

NuGet NuGet Downloads Checks

Library for proper error handling with Option, Result, AsyncResult and their computation expressions.

Inspiration

Install

paket add Feather.ErrorHandling

Note: You can also use this library in a Fable project.

Validation

validation {} is applicative. It evaluates every binding joined with and! and collects all of their failures. You can bind a Result<'T, 'Failure> or a Validation<'T, 'Failure> directly.

open Feather.ErrorHandling

type Person = { Name: string; Age: int }

type PersonError =
    | NameEmpty
    | InvalidAge
    | AgeNegative
    | Underage

module Int32 =
    let tryParse (s: string) =
        match System.Int32.TryParse(s) with
        | true, value -> Some value
        | false, _ -> None

let validateName name = if name = "" then Error NameEmpty else Ok name

let createPerson name age: Validation<Person, PersonError> = validation {
    let! name = validateName name
    and! age = result {  // only one specific error may come from the result
        let! age = age |> Int32.tryParse |> Result.ofOption InvalidAge
        if age < 0 then return! Error AgeNegative
        if age < 18 then return! Error Underage

        return age
    }

    return { Name = name; Age = age }
}

createPerson "Alice" "30"     // Ok { Name = "Alice"; Age = 30 }
createPerson "Alice" "thirty" // Error [ InvalidAge ]
createPerson "" "-1"          // Error [ NameEmpty; AgeNegative ]
createPerson "Alice" "16"     // Error [ Underage ]

A Validation<'T, 'Failure> is a Result<'T, 'Failure list>, so when a stage should run only if the previous one succeeded, bind the stages in an outer result {}.

Release

  1. Increment version in ErrorHandling.fsproj
  2. Update CHANGELOG.md
  3. Commit new version and tag it

Development

Requirements

Build

./build.sh build

Tests

./build.sh -t tests
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on Feather.ErrorHandling:

Package Downloads
Alma.Logging

Library for Logging to the terminal.

Alma.Kafka

Library for reading messages or producing messages to/from stream.

Alma.State

Library for handling internal memory state (_concurrently, etc._).

Alma.Tracing

A library to help with tracing.

Alma.Metrics

Library for showing app metrics for prometheus.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 40 9/25/2026
2.0.0 16,188 12/4/2025
1.0.0 1,808 11/26/2025