File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
swift/example_code/swift-sdk/retry/Sources Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 55// Swift. This example uses Amazon S3, but the same principle applies to every
66// AWS service.
77
8- import Foundation
98import AWSS3
9+ import Foundation
10+ // snippet-start:[retry.swift.imports]
1011import SmithyRetries
1112import SmithyRetriesAPI
13+ // snippet-start:[retry.swift.imports]
1214
1315@main
1416struct RetryExample {
@@ -17,8 +19,8 @@ struct RetryExample {
1719 let config : S3Client . S3ClientConfiguration
1820
1921 // Create an Amazon S3 client configuration object that specifies the
20- // standard exponential backoff strategy, adaptive retry mode and the
21- // base maximum number of retries as 5 .
22+ // adaptive retry mode and sets the maximum number of attempts to 3.
23+ // If that fails, create a default configuration instead .
2224
2325 do {
2426 // snippet-start:[retry.swift.configure]
@@ -28,9 +30,13 @@ struct RetryExample {
2830 )
2931 // snippet-end:[retry.swift.configure]
3032 } catch {
31- print ( " Error: Unable to create configuration " )
32- dump ( error)
33- exit ( 1 )
33+ do {
34+ config = try await S3Client . S3ClientConfiguration ( )
35+ } catch {
36+ print ( " Error: Unable to configure Amazon S3. " )
37+ dump ( error)
38+ return
39+ }
3440 }
3541
3642 // Create an Amazon S3 client using the configuration created above.
@@ -52,9 +58,9 @@ struct RetryExample {
5258 print ( " \( bucket. name ?? " <unknown> " ) " )
5359 }
5460 } catch {
55- print ( " Error: Unable to get list of buckets " )
61+ print ( " Error: Unable to get a list of buckets. " )
5662 dump ( error)
57- exit ( 2 )
63+ return
5864 }
5965 }
6066}
You can’t perform that action at this time.
0 commit comments