concept error detail in category c#

appears as: error details
Functional Programming in C#: How to write better C# code

This is an excerpt from Manning's book Functional Programming in C#: How to write better C# code.

There are a couple of obvious shortcomings in the overall solution. First, we’re effectively using Option to stop the computation if something goes wrong along the way, but we’re not giving any feedback to the user as to whether the request was successful or why. In chapter 6, you’ll see how to remedy this with Either and related structures; this allows you to capture error details without fundamentally altering the approach shown here.

Listing 6.1. Capturing error details with Either
using static System.Math; Either<string, double> Calc(double x, double y) { if (y == 0) return "y cannot be 0"; if (x != 0 && Sign(x) != Sign(y)) return "x / y cannot be negative"; return Sqrt(x / y); }