From ae08b5875d4ab349b4feec8670fa535cd0a0bfde Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Tue, 20 Jun 2023 11:32:59 -0500 Subject: [PATCH] Added async wrapper for TryWith and TryFinally in CE builder --- .../AsyncValidationCE.fs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/FsToolkit.ErrorHandling/AsyncValidationCE.fs b/src/FsToolkit.ErrorHandling/AsyncValidationCE.fs index 95dc507f..dd3b2578 100644 --- a/src/FsToolkit.ErrorHandling/AsyncValidationCE.fs +++ b/src/FsToolkit.ErrorHandling/AsyncValidationCE.fs @@ -44,20 +44,26 @@ module AsyncValidationCE = [] generator: unit -> AsyncValidation<'ok, 'error>, [] 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 ( [] generator: unit -> AsyncValidation<'ok, 'error>, [] compensation: unit -> unit ) : AsyncValidation<'ok, 'error> = - try - this.Run generator - finally - compensation () + async { + return! + try + this.Run generator + finally + compensation () + } member inline this.Using (