Skip to content

Commit

Permalink
Add errors that are common across services but are not documented
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Oct 26, 2020
1 parent af03044 commit aecde14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Sources/SotoCore/Errors/ClientErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ public struct AWSClientError: AWSErrorType {
case invalidParameterCombination = "InvalidParameterCombination"
case invalidParameterValue = "InvalidParameterValue"
case invalidQueryParameter = "InvalidQueryParameter"
case invalidSignature = "InvalidSignature"
case malformedQueryString = "MalformedQueryString"
case missingAction = "MissingAction"
case missingAuthenticationToken = "MissingAuthenticationToken"
case missingParameter = "MissingParameter"
case optInRequired = "OptInRequired"
case requestExpired = "RequestExpired"
case signatureDoesNotMatch = "SignatureDoesNotMatch"
case throttling = "Throttling"
case unrecognizedClient = "UnrecognizedClient"
case validationError = "ValidationError"
}

Expand Down Expand Up @@ -72,6 +75,8 @@ public struct AWSClientError: AWSErrorType {
public static var invalidParameterValue: AWSClientError { .init(.invalidParameterValue) }
// The AWS query string is malformed or does not adhere to AWS standards.
public static var invalidQueryParameter: AWSClientError { .init(.invalidQueryParameter) }
// Authorization signature is invalid.
public static var invalidSignature: AWSClientError { .init(.invalidSignature) }
// The query string contains a syntax error.
public static var malformedQueryString: AWSClientError { .init(.malformedQueryString) }
// The request is missing an action or a required parameter.
Expand All @@ -84,8 +89,12 @@ public struct AWSClientError: AWSErrorType {
public static var optInRequired: AWSClientError { .init(.optInRequired) }
// The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future. If you're using temporary security credentials, this error can also occur if the credentials have expired. For more information, see Temporary Security Credentials in the IAM User Guide.
public static var requestExpired: AWSClientError { .init(.requestExpired) }
// Authorization signature does not match the signature provided.
public static var signatureDoesNotMatch: AWSClientError { .init(.signatureDoesNotMatch) }
// The request was denied due to request throttling.
public static var throttling: AWSClientError { .init(.throttling) }
// AWS access key ID provided does not exist in our records.
public static var unrecognizedClient: AWSClientError { .init(.unrecognizedClient) }
// The input fails to satisfy the constraints specified by an AWS service.
public static var validationError: AWSClientError { .init(.validationError) }
}
Expand Down
6 changes: 5 additions & 1 deletion scripts/generate-errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct Error {
}
}

// list of errors comes from https://docs.aws.amazon.com/sns/latest/api/CommonErrors.html
let clientErrors: [Error] = [
// list of errors comes from https://docs.aws.amazon.com/sns/latest/api/CommonErrors.html
.init(name: "AccessDenied", description: "Access has been denied."),
.init(name: "IncompleteSignature", description: "The request signature does not conform to AWS standards."),
.init(name: "InvalidAction", description: "The action or operation requested is not valid. Verify that the action is typed correctly."),
Expand All @@ -51,6 +51,10 @@ let clientErrors: [Error] = [
.init(name: "RequestExpired", description: "The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future. If you're using temporary security credentials, this error can also occur if the credentials have expired. For more information, see Temporary Security Credentials in the IAM User Guide."),
.init(name: "Throttling", description: "The request was denied due to request throttling."),
.init(name: "ValidationError", description: "The input fails to satisfy the constraints specified by an AWS service."),
// additional errors that are common across a number of services
.init(name: "UnrecognizedClient", description: "AWS access key ID provided does not exist in our records."),
.init(name: "InvalidSignature", description: "Authorization signature is invalid."),
.init(name: "SignatureDoesNotMatch", description: "Authorization signature does not match the signature provided."),
]

let serverErrors: [Error] = [
Expand Down

0 comments on commit aecde14

Please sign in to comment.