diff --git a/swift/example_code/swift-sdk/retry/Sources/entry.swift b/swift/example_code/swift-sdk/retry/Sources/entry.swift index 705390c3319..7c671434ad6 100644 --- a/swift/example_code/swift-sdk/retry/Sources/entry.swift +++ b/swift/example_code/swift-sdk/retry/Sources/entry.swift @@ -6,9 +6,11 @@ // AWS service. import Foundation +// snippet-start:[retry.swift.imports] import AWSS3 import SmithyRetries import SmithyRetriesAPI +// snippet-end:[retry.swift.imports] @main struct RetryExample { @@ -17,8 +19,8 @@ struct RetryExample { let config: S3Client.S3ClientConfiguration // Create an Amazon S3 client configuration object that specifies the - // standard exponential backoff strategy, adaptive retry mode and the - // base maximum number of retries as 5. + // adaptive retry mode and sets the maximum number of attempts to 3. + // If that fails, create a default configuration instead. do { // snippet-start:[retry.swift.configure] @@ -28,9 +30,13 @@ struct RetryExample { ) // snippet-end:[retry.swift.configure] } catch { - print("Error: Unable to create configuration") - dump(error) - exit(1) + do { + config = try await S3Client.S3ClientConfiguration() + } catch { + print("Error: Unable to configure Amazon S3.") + dump(error) + return + } } // Create an Amazon S3 client using the configuration created above. @@ -52,9 +58,9 @@ struct RetryExample { print("\(bucket.name ?? "")") } } catch { - print("Error: Unable to get list of buckets") + print("Error: Unable to get a list of buckets.") dump(error) - exit(2) + return } } }