GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bfriesen/RandomSkunk.Results: A functional alternative to exception-based error handling in C#.

BranchesTags
Open more actions menu

Latest commit

 

History

388 Commits
388 Commits

Folders and files

NameName
Last commit message
Last commit date
ExampleBlazorApp.Client
ExampleBlazorApp.Client
 
 
ExampleBlazorApp.Server
ExampleBlazorApp.Server
 
 
ExampleBlazorApp.Shared
ExampleBlazorApp.Shared
 
 
Polyfill
Polyfill
 
 
RandomSkunk.Results.Analyzers.Tests
RandomSkunk.Results.Analyzers.Tests
 
 
RandomSkunk.Results.Analyzers
RandomSkunk.Results.Analyzers
 
 
RandomSkunk.Results.AspNetCore
RandomSkunk.Results.AspNetCore
 
 
RandomSkunk.Results.Dapper
RandomSkunk.Results.Dapper
 
 
RandomSkunk.Results.Http
RandomSkunk.Results.Http
 
 
RandomSkunk.Results.SourceGenerators
RandomSkunk.Results.SourceGenerators
 
 
RandomSkunk.Results.UnitTests
RandomSkunk.Results.UnitTests
 
 
RandomSkunk.Results
RandomSkunk.Results
 
 
docs
docs
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Directory.Build.targets
Directory.Build.targets
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RandomSkunk.Results.sln
RandomSkunk.Results.sln
 
 
THIRD-PARTY-NOTICES.txt
THIRD-PARTY-NOTICES.txt
 
 
icon.png
icon.png
 
 
stylecop.json
stylecop.json
 
 

Repository files navigation

RandomSkunk.Results

Two things that make code harder to reason about are exceptions and null. The libraries in this repository aim to do something about exceptions by providing "result" structs to explicitly represent what happened during an operation that could potentially fail. To address null, these results don't accept null as any sort of input and don't provide null from any output***.

There are three types of results:

  • Result
    • For operations that can fail and do not have a return value.
    • Can be either:
      • Success, or
      • Fail with a non-null Error object.
  • Result<T>
    • For operations that can fail and have a return value which is always provided.
    • Can be either:
      • Success with a non-null value, or
      • Fail with a non-null Error object.
  • Maybe<T>
    • For operations that can fail and have a return value which may or may not be provided.
    • Can be one of:
      • Success with a non-null value,
      • Fail with a non-null Error object, or
      • None indicating no value.

There are a number of libraries in this repository: the main library, and several that depend on the main library and provide result functionality in specific domains.

RandomSkunk.Results NuGet

The main library. Implementations of the Result monad.

RandomSkunk.Results.AspNetCore NuGet

Using RandomSkunk.Results from AspNetCore apps.

RandomSkunk.Results.Dapper NuGet

Using RandomSkunk.Results with Dapper.

RandomSkunk.Results.Http NuGet

Using RandomSkunk.Results with System.Net.Http and System.Net.Http.Json.


Example Project

The solution in this repository contains an example Blazor Web Assembly app that demonstrates how to use the RandomSkunk.Result libraries. To run the app, select the ExampleBlazorApp.Server project as the startup project.

These are the interesting parts of the example app (with links to the code):

  • ExampleBlazorApp.Client project
    • Typed HTTP Clients - each one uses RandomSkunk.Results.Http to make HTTP requests to the server
      • WeatherForcastClient
      • WeatherProfileClient
        • GetWeatherProfiles
        • AddWeatherProfile
        • EditWeatherProfile
    • Razor pages - each one uses one of the typed HTTP clients to make a request to the server, then handles the result
      • FiveDayForecast
      • WeatherProfiles
        • FetchWeatherProfiles
        • SaveProfile
  • ExampleBlazorApp.Server project
    • WeatherRepository - uses RandomSkunk.Results.Dapper to make queries to the database
      • GetMonthlyTemperature
      • GetWeatherProfiles
      • UpsertWeatherProfile
    • WeatherForecastSimulator - uses WeatherRepository to make queries to the database
    • Controllers
      • WeatherForecastController - uses WeatherForecastSimulator to simulate weather forecasts
      • WeatherProfilesController - uses WeatherRepository to make queries to the database
        • GetWeatherProfiles
        • AddWeatherProfile
        • EditWeatherProfile

About

A functional alternative to exception-based error handling in C#.

bfriesen.github.io/RandomSkunk.Results/

Topics

error-handlingmaybe-monadrailway-oriented-programmingresult-monad

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.