Skip to content

Commit c12aaac

Browse files
committed
Return ValueOption from Cosmos DB exception unwrappers
1 parent bf47dc6 commit c12aaac

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Cosmos/Cosmos.fs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ module Operations =
3434

3535
let internal unwrapCosmosException (ex : Exception) =
3636
match ex with
37-
| :? CosmosException as ex -> Some ex
37+
| :? CosmosException as ex -> ValueSome ex
3838
| :? AggregateException as ex ->
3939
match ex.InnerException with
40-
| :? CosmosException as cex -> Some cex
41-
| _ -> None
42-
| _ -> None
40+
| :? CosmosException as cex -> ValueSome cex
41+
| _ -> ValueNone
42+
| _ -> ValueNone
4343

4444
let internal handleException (ex : Exception) =
4545
let cosmosException = unwrapCosmosException ex
4646
match cosmosException with
47-
| Some ex when canHandleStatusCode ex.StatusCode -> Some ex
48-
| _ -> None
47+
| ValueSome ex when canHandleStatusCode ex.StatusCode -> ValueSome ex
48+
| _ -> ValueNone
4949

50+
[<return : Struct>]
5051
let (|CosmosException|_|) (ex : Exception) = unwrapCosmosException ex
5152

53+
[<return : Struct>]
5254
let (|HandleException|_|) (ex : Exception) = handleException ex
5355

5456
let internal retryUpdate toErrorResult executeConcurrentlyAsync maxRetryCount currentAttemptCount (e : CosmosException) =

0 commit comments

Comments
 (0)