diff --git a/Sources/SimpleNotificationClient/AWSSimpleNotificationClient.swift b/Sources/SimpleNotificationClient/AWSSimpleNotificationClient.swift index 7f0fdae..7a9db4e 100644 --- a/Sources/SimpleNotificationClient/AWSSimpleNotificationClient.swift +++ b/Sources/SimpleNotificationClient/AWSSimpleNotificationClient.swift @@ -43,7 +43,7 @@ public enum SimpleNotificationClientError: Swift.Error { public func isRetriable() -> Bool? { switch self { - case .filterPolicyLimitExceeded, .kMSThrottling, .subscriptionLimitExceeded, .throttled, .topicLimitExceeded: + case .filterPolicyLimitExceeded, .kMSThrottling, .subscriptionLimitExceeded, .throttled, .throttling, .topicLimitExceeded: return true default: return nil diff --git a/Sources/SimpleNotificationModel/SimpleNotificationModelErrors.swift b/Sources/SimpleNotificationModel/SimpleNotificationModelErrors.swift index 5650e41..12b5c55 100644 --- a/Sources/SimpleNotificationModel/SimpleNotificationModelErrors.swift +++ b/Sources/SimpleNotificationModel/SimpleNotificationModelErrors.swift @@ -62,6 +62,7 @@ private let subscriptionLimitExceededIdentity = "SubscriptionLimitExceeded" private let tagLimitExceededIdentity = "TagLimitExceeded" private let tagPolicyIdentity = "TagPolicy" private let throttledIdentity = "Throttled" +private let throttlingIdentity = "Throttling" private let tooManyEntriesInBatchRequestIdentity = "TooManyEntriesInBatchRequest" private let topicLimitExceededIdentity = "TopicLimitExceeded" private let userErrorIdentity = "UserError" @@ -69,6 +70,16 @@ private let validationIdentity = "ValidationException" private let verificationIdentity = "VerificationException" private let __accessDeniedIdentity = "AccessDenied" +public struct SimpleNotificationErrorPayload: Codable { + public let type: String + public let message: String + + enum CodingKeys: String, CodingKey { + case type = "Code" + case message = "Message" + } +} + public enum SimpleNotificationError: Swift.Error, Decodable { case authorizationError(AuthorizationErrorException) case batchEntryIdsNotDistinct(BatchEntryIdsNotDistinctException) @@ -99,6 +110,7 @@ public enum SimpleNotificationError: Swift.Error, Decodable { case tagLimitExceeded(TagLimitExceededException) case tagPolicy(TagPolicyException) case throttled(ThrottledException) + case throttling(SimpleNotificationErrorPayload) case tooManyEntriesInBatchRequest(TooManyEntriesInBatchRequestException) case topicLimitExceeded(TopicLimitExceededException) case userError(UserErrorException) @@ -210,6 +222,9 @@ public enum SimpleNotificationError: Swift.Error, Decodable { case throttledIdentity: let errorPayload = try ThrottledException(from: decoder) self = SimpleNotificationError.throttled(errorPayload) + case throttlingIdentity: + let errorPayload = try SimpleNotificationErrorPayload(from: decoder) + self = SimpleNotificationError.throttling(errorPayload) case tooManyEntriesInBatchRequestIdentity: let errorPayload = try TooManyEntriesInBatchRequestException(from: decoder) self = SimpleNotificationError.tooManyEntriesInBatchRequest(errorPayload)