Decepticon.GenericResult 1.0.1

Install-Package Decepticon.GenericResult -Version 1.0.1
dotnet add package Decepticon.GenericResult --version 1.0.1
<PackageReference Include="Decepticon.GenericResult" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Decepticon.GenericResult --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Decepticon.GenericResult, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Decepticon.GenericResult as a Cake Addin
#addin nuget:?package=Decepticon.GenericResult&version=1.0.1

// Install Decepticon.GenericResult as a Cake Tool
#tool nuget:?package=Decepticon.GenericResult&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

A super lightweight handy utility to return a result with a value on success or errors on failure. Better error handling.

Quickly why?

  • Results with errors allow you to handle errors in your application properly. Let's say a function that returns a boolean can be true, false, or errors.
  • Clean code. The method returns errors and value at once.

Why use this package?

  • Super lightweight
  • Free + opensource
  • Easy to use
  • Simple, look at the code below
  • Support earlier version of .NetFramework and .NetCore

Usages

using Decepticon.GenericResult;
...
void ResultDemo()
{
    var result = Divide(108.0, 9);
    if (result.IsFailed)
    {
        Console.WriteLine(result.Error);
    }

    Console.WriteLine(result.Value);
}

Result<double> Divide(double dividen, double divider)
{
    if (divider == 0.0)
    {
        Result.Fail("Cannot divide by zero");
    }

    var someNumber = dividen / divider;
    return Result.Succeed(someNumber);
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 164 9/27/2020
1.0.0 163 9/24/2020

Include doc summaries