awslabs / aws-sdk-swift

Apache License 2.0
401 stars 80 forks source link

Add custom types for common errors #1058

Open shepazon opened 1 year ago

shepazon commented 1 year ago

Describe the feature

Due to the way many services are designed, not all errors are modeled in a way that results in types being generated for Swift automatically. Please add custom types for common errors that occur, such as the AccessDenied error returned by S3 and probably many other services.

Use Case

There are important errors you can't currently catch, such as AccessDenied. Letting developers catch these will make application development easier, and will result in more reliable and performant software for our customers.

Proposed Solution

Add the needed custom types so that errors like AccessDenied can be caught like any fully-modeled error:

do {
    let output = s3client.listBuckets(input: ListBucketsInput())
    ...
} catch let error as AccessDenied {
    // handle the access denied error by prompting the user to log in,
    // for example.
}

Other Information

No response

Acknowledgements

jbelkins commented 1 year ago

Look for a list of these types of unmodeled yet common errors

jbelkins commented 6 months ago

https://docs.aws.amazon.com/awssupport/latest/APIReference/CommonErrors.html

These are the errors which AWS says may be thrown by any service. These should be modeled as custom error types in the SDK and returned in place of an UnknownAWSHTTPServiceError.