Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about possibly unreachable try-catch with Async jobs #686

Open
knocte opened this issue Jan 20, 2024 · 0 comments
Open

Warn about possibly unreachable try-catch with Async jobs #686

knocte opened this issue Jan 20, 2024 · 0 comments

Comments

@knocte
Copy link
Collaborator

knocte commented Jan 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant