Sometimes when we want to add a try-catch to a certain asynchronous function, we go from:
let Foo(): Async<'Bar> =
DoSomething()
to:
let Foo(): Async<'Bar> =
try
DoSomething()
with
| ex -> DoSomethingElse()
However, most of the time, the above change is wrong, because the exception only happens when the async job is running, not when the async job is being composed (as it's happening in the above). If we had added the try-with block inside an async{} block, this would have been fine.
Maybe we could create a rule that warns against this, and recommends converting 'Bar to Result<'Bar,'Err> instead.
Sometimes when we want to add a try-catch to a certain asynchronous function, we go from:
to:
However, most of the time, the above change is wrong, because the exception only happens when the async job is running, not when the async job is being composed (as it's happening in the above). If we had added the try-with block inside an async{} block, this would have been fine.
Maybe we could create a rule that warns against this, and recommends converting 'Bar to Result<'Bar,'Err> instead.