Using LanguageExt to handle Exceptions and nulls in ASP.NET Core web API
Data served from {JSON} Placeholder. The Users endpoint returns 10 users. The User/{id} endpoint returns users 1-10 or NotFound.
Commonly, we model the interaction with the world outside the application with Task<T>
; things that go in the external (Infrastructure) zone of a Clean Architecture desing pattern, SQL Connections, HttpClients, File IO. But Task<T>
is a poor representation of an interaction that can get messy very soon, leaving to the developers to handle nulls, exceptions, etc. Aff<T>
from LanguageExt offers an alternative with richier error handling capabilities. The current project is a minimalistic sample of it use.
Reference: How to deal with side effects