Skip to content

Commit

Permalink
Added async wrapper for TryWith and TryFinally in CE builder
Browse files Browse the repository at this point in the history
  • Loading branch information
1eyewonder authored and TheAngryByrd committed Jun 21, 2023
1 parent 521ee3c commit ae08b58
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/FsToolkit.ErrorHandling/AsyncValidationCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,26 @@ module AsyncValidationCE =
[<InlineIfLambda>] generator: unit -> AsyncValidation<'ok, 'error>,
[<InlineIfLambda>] handler: exn -> AsyncValidation<'ok, 'error>
) : AsyncValidation<'ok, 'error> =
try
this.Run generator
with e ->
handler e
async {
return!
try
this.Run generator
with e ->
handler e
}

member inline this.TryFinally
(
[<InlineIfLambda>] generator: unit -> AsyncValidation<'ok, 'error>,
[<InlineIfLambda>] compensation: unit -> unit
) : AsyncValidation<'ok, 'error> =
try
this.Run generator
finally
compensation ()
async {
return!
try
this.Run generator
finally
compensation ()
}

member inline this.Using
(
Expand Down

0 comments on commit ae08b58

Please sign in to comment.