Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional AWS error functions #37

Merged
merged 9 commits into from
Jun 12, 2020
Merged

Additional AWS error functions #37

merged 9 commits into from
Jun 12, 2020

Conversation

ewbankkit
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Reference: hashicorp/terraform-provider-aws#13036.

Additional AWS error code functions used within the AWS Provider to be migrated here so that they can be used in other contexts.

Relevant unit tests:

$ go test -v ./...
=== RUN   TestIsAwsErr
=== RUN   TestIsAwsErr/nil_error
=== RUN   TestIsAwsErr/nil_error_code
=== RUN   TestIsAwsErr/nil_error_message
=== RUN   TestIsAwsErr/nil_error_code_and_message
=== RUN   TestIsAwsErr/other_error
=== RUN   TestIsAwsErr/other_error_code
=== RUN   TestIsAwsErr/other_error_message
=== RUN   TestIsAwsErr/other_error_code_and_message
=== RUN   TestIsAwsErr/awserr_error_matching_code_and_no_message
=== RUN   TestIsAwsErr/awserr_error_matching_code_and_matching_message_exact
=== RUN   TestIsAwsErr/awserr_error_matching_code_and_matching_message_contains
=== RUN   TestIsAwsErr/awserr_error_matching_code_and_non-matching_message
=== RUN   TestIsAwsErr/awserr_error_no_code
=== RUN   TestIsAwsErr/awserr_error_no_code_and_matching_message_exact
=== RUN   TestIsAwsErr/awserr_error_non-matching_code
=== RUN   TestIsAwsErr/awserr_error_non-matching_code_and_message_exact
=== RUN   TestIsAwsErr/wrapped_other_error
=== RUN   TestIsAwsErr/wrapped_other_error_code
=== RUN   TestIsAwsErr/wrapped_other_error_message
=== RUN   TestIsAwsErr/wrapped_other_error_code_and_message
=== RUN   TestIsAwsErr/wrapped_awserr_error_matching_code_and_no_message
=== RUN   TestIsAwsErr/wrapped_awserr_error_matching_code_and_matching_message_exact
=== RUN   TestIsAwsErr/wrapped_awserr_error_matching_code_and_matching_message_contains
=== RUN   TestIsAwsErr/wrapped_awserr_error_matching_code_and_non-matching_message
=== RUN   TestIsAwsErr/wrapped_awserr_error_no_code
=== RUN   TestIsAwsErr/wrapped_awserr_error_no_code_and_matching_message_exact
=== RUN   TestIsAwsErr/wrapped_awserr_error_non-matching_code
=== RUN   TestIsAwsErr/wrapped_awserr_error_non-matching_code_and_message_exact
--- PASS: TestIsAwsErr (0.00s)
    --- PASS: TestIsAwsErr/nil_error (0.00s)
    --- PASS: TestIsAwsErr/nil_error_code (0.00s)
    --- PASS: TestIsAwsErr/nil_error_message (0.00s)
    --- PASS: TestIsAwsErr/nil_error_code_and_message (0.00s)
    --- PASS: TestIsAwsErr/other_error (0.00s)
    --- PASS: TestIsAwsErr/other_error_code (0.00s)
    --- PASS: TestIsAwsErr/other_error_message (0.00s)
    --- PASS: TestIsAwsErr/other_error_code_and_message (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_matching_code_and_no_message (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_matching_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_matching_code_and_matching_message_contains (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_matching_code_and_non-matching_message (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_no_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAwsErr/awserr_error_non-matching_code_and_message_exact (0.00s)
    --- PASS: TestIsAwsErr/wrapped_other_error (0.00s)
    --- PASS: TestIsAwsErr/wrapped_other_error_code (0.00s)
    --- PASS: TestIsAwsErr/wrapped_other_error_message (0.00s)
    --- PASS: TestIsAwsErr/wrapped_other_error_code_and_message (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_matching_code_and_no_message (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_matching_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_matching_code_and_matching_message_contains (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_matching_code_and_non-matching_message (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_no_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAwsErr/wrapped_awserr_error_non-matching_code_and_message_exact (0.00s)
=== RUN   TestIsAwsErrExtended
=== RUN   TestIsAwsErrExtended/nil_error
=== RUN   TestIsAwsErrExtended/nil_error_code
=== RUN   TestIsAwsErrExtended/nil_error_message
=== RUN   TestIsAwsErrExtended/nil_error_code_and_message
=== RUN   TestIsAwsErrExtended/nil_error_code,_message,_and_extended_message
=== RUN   TestIsAwsErrExtended/other_error
=== RUN   TestIsAwsErrExtended/other_error_code
=== RUN   TestIsAwsErrExtended/other_error_message
=== RUN   TestIsAwsErrExtended/other_error_code_and_message
=== RUN   TestIsAwsErrExtended/other_error_code,_message,_and_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_no_message,_and_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_exact,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_exact,_and_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_contains,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_contains,_and_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_non-matching_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_no_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_no_code,_matching_message_exact,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_non-matching_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_non-extended_error_non-matching_code,_matching_message_exact,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_matching_extended_message_exact
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_matching_extended_message_contains
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_matching_extended_message_exact
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_matching_extended_message_contains
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_contains,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_contains,_and_matching_extended_message_contains
=== RUN   TestIsAwsErrExtended/awserr_extended_error_matching_code,_non-matching_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_no_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_no_code,_matching_message_exact,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_non-matching_code,_no_message,_and_no_extended_message
=== RUN   TestIsAwsErrExtended/awserr_extended_error_non-matching_code,_matching_message_exact,_and_no_extended_message
--- PASS: TestIsAwsErrExtended (0.01s)
    --- PASS: TestIsAwsErrExtended/nil_error (0.00s)
    --- PASS: TestIsAwsErrExtended/nil_error_code (0.00s)
    --- PASS: TestIsAwsErrExtended/nil_error_message (0.00s)
    --- PASS: TestIsAwsErrExtended/nil_error_code_and_message (0.00s)
    --- PASS: TestIsAwsErrExtended/nil_error_code,_message,_and_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/other_error (0.00s)
    --- PASS: TestIsAwsErrExtended/other_error_code (0.00s)
    --- PASS: TestIsAwsErrExtended/other_error_message (0.00s)
    --- PASS: TestIsAwsErrExtended/other_error_code_and_message (0.00s)
    --- PASS: TestIsAwsErrExtended/other_error_code,_message,_and_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_no_message,_and_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_exact,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_exact,_and_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_contains,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_matching_message_contains,_and_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_matching_code,_non-matching_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_no_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_no_code,_matching_message_exact,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_non-matching_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_non-extended_error_non-matching_code,_matching_message_exact,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_matching_extended_message_exact (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_no_message,_and_matching_extended_message_contains (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_matching_extended_message_exact (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_exact,_and_matching_extended_message_contains (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_contains,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_matching_message_contains,_and_matching_extended_message_contains (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_matching_code,_non-matching_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_no_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_no_code,_matching_message_exact,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_non-matching_code,_no_message,_and_no_extended_message (0.00s)
    --- PASS: TestIsAwsErrExtended/awserr_extended_error_non-matching_code,_matching_message_exact,_and_no_extended_message (0.00s)
=== RUN   TestIsAwsErrCode
=== RUN   TestIsAwsErrCode/nil_error
=== RUN   TestIsAwsErrCode/nil_error_code
=== RUN   TestIsAwsErrCode/other_error
=== RUN   TestIsAwsErrCode/other_error_code
=== RUN   TestIsAwsErrCode/awserr_error_matching_code
=== RUN   TestIsAwsErrCode/awserr_error_no_code
=== RUN   TestIsAwsErrCode/awserr_error_non-matching_code
=== RUN   TestIsAwsErrCode/wrapped_other_error
=== RUN   TestIsAwsErrCode/wrapped_other_error_code
=== RUN   TestIsAwsErrCode/wrapped_awserr_error_matching_code
=== RUN   TestIsAwsErrCode/wrapped_awserr_error_no_code
=== RUN   TestIsAwsErrCode/wrapped_awserr_error_non-matching_code
--- PASS: TestIsAwsErrCode (0.00s)
    --- PASS: TestIsAwsErrCode/nil_error (0.00s)
    --- PASS: TestIsAwsErrCode/nil_error_code (0.00s)
    --- PASS: TestIsAwsErrCode/other_error (0.00s)
    --- PASS: TestIsAwsErrCode/other_error_code (0.00s)
    --- PASS: TestIsAwsErrCode/awserr_error_matching_code (0.00s)
    --- PASS: TestIsAwsErrCode/awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErrCode/awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAwsErrCode/wrapped_other_error (0.00s)
    --- PASS: TestIsAwsErrCode/wrapped_other_error_code (0.00s)
    --- PASS: TestIsAwsErrCode/wrapped_awserr_error_matching_code (0.00s)
    --- PASS: TestIsAwsErrCode/wrapped_awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErrCode/wrapped_awserr_error_non-matching_code (0.00s)
=== RUN   TestIsAwsErrCodeContains
=== RUN   TestIsAwsErrCodeContains/nil_error
=== RUN   TestIsAwsErrCodeContains/nil_error_code
=== RUN   TestIsAwsErrCodeContains/other_error
=== RUN   TestIsAwsErrCodeContains/other_error_code
=== RUN   TestIsAwsErrCodeContains/awserr_error_matching_code
=== RUN   TestIsAwsErrCodeContains/awserr_error_contains_code
=== RUN   TestIsAwsErrCodeContains/awserr_error_no_code
=== RUN   TestIsAwsErrCodeContains/awserr_error_non-matching_code
=== RUN   TestIsAwsErrCodeContains/wrapped_other_error
=== RUN   TestIsAwsErrCodeContains/wrapped_other_error_code
=== RUN   TestIsAwsErrCodeContains/wrapped_awserr_error_matching_code
=== RUN   TestIsAwsErrCodeContains/wrapped_awserr_error_contains_code
=== RUN   TestIsAwsErrCodeContains/wrapped_awserr_error_no_code
=== RUN   TestIsAwsErrCodeContains/wrapped_awserr_error_non-matching_code
--- PASS: TestIsAwsErrCodeContains (0.01s)
    --- PASS: TestIsAwsErrCodeContains/nil_error (0.00s)
    --- PASS: TestIsAwsErrCodeContains/nil_error_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/other_error (0.00s)
    --- PASS: TestIsAwsErrCodeContains/other_error_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/awserr_error_matching_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/awserr_error_contains_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_other_error (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_other_error_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_awserr_error_matching_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_awserr_error_contains_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_awserr_error_no_code (0.00s)
    --- PASS: TestIsAwsErrCodeContains/wrapped_awserr_error_non-matching_code (0.00s)
=== RUN   TestIsAWSErrCodeMessageContains
=== RUN   TestIsAWSErrCodeMessageContains/nil_error
=== RUN   TestIsAWSErrCodeMessageContains/nil_error_code
=== RUN   TestIsAWSErrCodeMessageContains/nil_error_message
=== RUN   TestIsAWSErrCodeMessageContains/nil_error_code_and_message
=== RUN   TestIsAWSErrCodeMessageContains/other_error
=== RUN   TestIsAWSErrCodeMessageContains/other_error_code
=== RUN   TestIsAWSErrCodeMessageContains/other_error_message
=== RUN   TestIsAWSErrCodeMessageContains/other_error_code_and_message
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_no_message
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_matching_message_exact
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_matching_message_contains
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_non-matching_message
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_no_code
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_no_code_and_matching_message_exact
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_non-matching_code
=== RUN   TestIsAWSErrCodeMessageContains/awserr_error_non-matching_code_and_message_exact
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_other_error
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_other_error_code
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_other_error_message
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_other_error_code_and_message
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_no_message
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_matching_message_exact
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_matching_message_contains
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_non-matching_message
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_no_code
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_no_code_and_matching_message_exact
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_non-matching_code
=== RUN   TestIsAWSErrCodeMessageContains/wrapped_awserr_error_non-matching_code_and_message_exact
--- PASS: TestIsAWSErrCodeMessageContains (0.01s)
    --- PASS: TestIsAWSErrCodeMessageContains/nil_error (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/nil_error_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/nil_error_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/nil_error_code_and_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/other_error (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/other_error_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/other_error_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/other_error_code_and_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_no_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_matching_message_contains (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_matching_code_and_non-matching_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_no_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_no_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/awserr_error_non-matching_code_and_message_exact (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_other_error (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_other_error_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_other_error_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_other_error_code_and_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_no_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_matching_message_contains (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_matching_code_and_non-matching_message (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_no_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_no_code_and_matching_message_exact (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_non-matching_code (0.00s)
    --- PASS: TestIsAWSErrCodeMessageContains/wrapped_awserr_error_non-matching_code_and_message_exact (0.00s)
=== RUN   TestIsAWSErrRequestFailureStatusCode
=== RUN   TestIsAWSErrRequestFailureStatusCode/nil_error
=== RUN   TestIsAWSErrRequestFailureStatusCode/nil_error_status_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/other_error
=== RUN   TestIsAWSErrRequestFailureStatusCode/other_error_status_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/awserr_error_matching_status_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/awserr_error_non-matching_statuc_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/wrapped_other_error
=== RUN   TestIsAWSErrRequestFailureStatusCode/wrapped_other_status_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/wrapped_awserr_error_matching_status_code
=== RUN   TestIsAWSErrRequestFailureStatusCode/wrapped_awserr_error_non-matching_status_code
--- PASS: TestIsAWSErrRequestFailureStatusCode (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/nil_error (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/nil_error_status_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/other_error (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/other_error_status_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/awserr_error_matching_status_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/awserr_error_non-matching_statuc_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/wrapped_other_error (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/wrapped_other_status_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/wrapped_awserr_error_matching_status_code (0.00s)
    --- PASS: TestIsAWSErrRequestFailureStatusCode/wrapped_awserr_error_non-matching_status_code (0.00s)

awserr.go Outdated Show resolved Hide resolved
@ewbankkit ewbankkit requested a review from a team as a code owner June 3, 2020 17:54
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had some ideas about renaming

awserr.go Outdated
// IsAWSErrCode returns true if the error matches all these conditions:
// * err is of type awserr.Error
// * Error.Code() equals code
func IsAWSErrCode(err error, code string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did some workshopping on the functions, since some of the names like IsAWSErrCodeMessageContains() didn't read smoothly.

We came up with moving them to a package tfawserr and the following renaming:

  • IsAWSErrCode() to ErrCodeEquals()
  • IsAWSErrCodeContains() to ErrCodeContains()
  • IsAWSErrCodeMessageContains() to ErrMessageContains()
  • IsAWSErrRequestFailureStatusCode() to ErrStatusCodeEquals()

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.
Do we still want to keep IsAWSErr in the top-level package? Removing it would be a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably leave it for backwards compatibility, even though we're pre-1.0 :)

Copy link
Contributor Author

@ewbankkit ewbankkit Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel comfortable removing IsAWSErr as the only usage I can find external to this repo is in the AWS Provider.
And that's a single call.

Copy link
Contributor

@bflad bflad Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please feel free to making breaking Go API changes in this library -- its noted in the README that its only intended for usage by the Terraform S3 Backend and Terraform AWS Provider and each of those should have a small usage footprint currently. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have just done that 😄, with appropriate CHANGELOG entries.

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Two cases where the error check can be simplified

session_test.go Outdated Show resolved Hide resolved
@gdavison gdavison merged commit 91541fe into hashicorp:master Jun 12, 2020
@ewbankkit ewbankkit deleted the f-additional-aws-error-funcs branch June 12, 2020 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants