You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to handle request results that may contain errors and I want to filter away the error into an exception. An example of what I'm trying to accomplish is the following code. When the status of the result is Error I want to filter it away into a RequestError with the given message, but the API only allows constant values for the exceptional value.
return result.Map(json => JsonConvert.DeserializeObject<StatusEnvelope<RouteData>>(json))
.Filter(e => e.Status == "Error", e => new RequestError(e.Error))
.Map(re => re.Value);
The best solution I could come up with is rather verbose:
I need to handle request results that may contain errors and I want to filter away the error into an exception. An example of what I'm trying to accomplish is the following code. When the status of the result is
Error
I want to filter it away into aRequestError
with the given message, but the API only allows constant values for the exceptional value.The best solution I could come up with is rather verbose:
Suggested addition to the API:
public Option<T, TException> Filter(Func<T, bool> predicate, Func<T, TException> exception);
The text was updated successfully, but these errors were encountered: