I use LangExt library and i have the case of no user exists with UserId 1.
public async Task<Option<UserViewModel> GetUser()
=> await GetUser(1)
.MapAsync(this.alterName)
.MapAsync(this.alterCountry)
.MapAsync(this.applyMoreChange)
.Map(this.mapper.map<ViewModel>);
since no user exists for userId 1, the GetUser(1) returns Option<None> and the remaining code fails with the exception
LangExt.ValueIsNoneException : Value is None.
at languageExt.OptionAsyncAwaiter`1.GetResult()
How to handle this case.? and to make sure the mapAsync and map chaining execute only if option is some user and not none.
This page on github seems to indicate that option will have a .IfSome() function. The github gives the following code snippet:
A suggestion on implementation (without knowing the full idea of your project) would be something like this: