Skip to content

Commit ae08b58

Browse files
1eyewonderTheAngryByrd
authored andcommitted
Added async wrapper for TryWith and TryFinally in CE builder
1 parent 521ee3c commit ae08b58

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/FsToolkit.ErrorHandling/AsyncValidationCE.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,26 @@ module AsyncValidationCE =
4444
[<InlineIfLambda>] generator: unit -> AsyncValidation<'ok, 'error>,
4545
[<InlineIfLambda>] handler: exn -> AsyncValidation<'ok, 'error>
4646
) : AsyncValidation<'ok, 'error> =
47-
try
48-
this.Run generator
49-
with e ->
50-
handler e
47+
async {
48+
return!
49+
try
50+
this.Run generator
51+
with e ->
52+
handler e
53+
}
5154

5255
member inline this.TryFinally
5356
(
5457
[<InlineIfLambda>] generator: unit -> AsyncValidation<'ok, 'error>,
5558
[<InlineIfLambda>] compensation: unit -> unit
5659
) : AsyncValidation<'ok, 'error> =
57-
try
58-
this.Run generator
59-
finally
60-
compensation ()
60+
async {
61+
return!
62+
try
63+
this.Run generator
64+
finally
65+
compensation ()
66+
}
6167

6268
member inline this.Using
6369
(

0 commit comments

Comments
 (0)