Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nested ProvisionedThroughputExceeded #363

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Equinox.DynamoStore/DynamoStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,9 +1388,15 @@ type DynamoStoreCategory<'event, 'state, 'context>(resolveInner, empty) =

module Exceptions =

let [<return: Struct>] (|ProvisionedThroughputExceeded|_|) : exn -> unit voption = function
| :? Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException -> ValueSome ()
| _ -> ValueNone
let rec private anyInnerIs predicate (x : AggregateException) =
match x.InnerException with
| :? AggregateException as iae -> anyInnerIs predicate iae
| ie -> predicate ie
let private exceptionOrAnyInnerIs predicate : exn -> bool = function
| :? AggregateException as e -> e |> anyInnerIs predicate
| e -> predicate e
let isThrottlingExn (x : exn) = x :? Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException
let [<return: Struct>] (|ProvisionedThroughputExceeded|_|) e = if exceptionOrAnyInnerIs isThrottlingExn e then ValueSome () else ValueNone

namespace Equinox.DynamoStore.Core

Expand Down