Great article, trying to wrap my had around F# this days and articles like that, real world scenarios like wrapping third party dlls or my own for example are great examples how to it would look like working on real F# project, i do wonder though after walking through the gist as well, where is the error handling staff?
Thanks for the reply, glad you liked it. The error handling is no different than it would be in C# here: callers would need to be prepared to handle HttpRequestException (or an AggregateException with an inner HttpRequestException due to the Task) for network errors, and TaskCanceledException if you're using timeouts.
In my own code I often catch and convert those exceptions to Results, but that's somewhat opinionated and felt beyond the scope of this post.
Also, non-200 status codes will not throw and can be handled through pattern matching
Great article, trying to wrap my had around F# this days and articles like that, real world scenarios like wrapping third party dlls or my own for example are great examples how to it would look like working on real F# project, i do wonder though after walking through the gist as well, where is the error handling staff?
Thanks for the reply, glad you liked it. The error handling is no different than it would be in C# here: callers would need to be prepared to handle
HttpRequestException
(or anAggregateException
with an innerHttpRequestException
due to theTask
) for network errors, andTaskCanceledException
if you're using timeouts.In my own code I often catch and convert those exceptions to
Result
s, but that's somewhat opinionated and felt beyond the scope of this post.Also, non-200 status codes will not throw and can be handled through pattern matching
Thanks for finding the time to reply,
much appriciated