Skip to content

Commit

Permalink
Use awaitTaskWithInnerException instead of AsyncAwaitTask in ofTask, …
Browse files Browse the repository at this point in the history
…and ofUnitTask.
  • Loading branch information
Jamil Maqdis Anton committed Nov 30, 2020
1 parent 29f9c8e commit 886029d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/AsyncOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ module AsyncOption =
let ofOption (option: 'a option): AsyncOption<'a> = Async.singleton option

let ofTask (lazyTask: unit -> Task<'a>): AsyncOption<'a> =
async.Delay(lazyTask >> Async.AwaitTask)
async.Delay(lazyTask >> Async.awaitTaskWithInnerException)
|> Async.Catch
|> Async.map Option.ofChoice

let ofUnitTask (lazyTask: unit -> Task): AsyncOption<unit> =
async.Delay(lazyTask >> Async.AwaitTask)
async.Delay(lazyTask >> Async.awaitUnitTaskWithInnerException)
|> Async.Catch
|> Async.map Option.ofChoice

Expand Down
6 changes: 4 additions & 2 deletions src/AsyncResult.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ module AsyncResult =
let ofResult (result: Result<'a, 'e>): AsyncResult<'a, 'e> = Async.singleton result

let ofTask (lazyTask: unit -> Task<'a>): AsyncResult<'a, exn> =
async.Delay(lazyTask >> Async.AwaitTask)
async.Delay(lazyTask >> Async.awaitTaskWithInnerException)
|> Async.Catch
|> Async.map Result.ofChoice

let ofUnitTask (lazyUnitTask: unit -> Task): AsyncResult<unit, exn> =
async.Delay(lazyUnitTask >> Async.AwaitTask)
async.Delay
(lazyUnitTask
>> Async.awaitUnitTaskWithInnerException)
|> Async.Catch
|> Async.map Result.ofChoice

Expand Down

0 comments on commit 886029d

Please sign in to comment.