Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 1
    But that the user already exists is only one of more ways that the API call can fail. I don't see a way to differentiate between these with this method. Commented Oct 11, 2015 at 17:49
  • 1
    Thanks for that. That only enforces my suspicion that this question is more boto3-specific that python-specific. I am not aware of common patterns for error handling in python, hence my generic way of asking the question Commented Oct 11, 2015 at 17:52
  • 1
    I have got the source for the ClientError exception right here: github.com/boto/botocore/blob/develop/botocore/…. Doesn't that look like it just gets formatted in a string? May be a "problem" with the way boto3 handles that kind of errors. Maybe the devs are assuming that there is only 2 possible scenarios (that the user already exists or doesn't) which justifies just throwing an exception with only a string if it didn't work. Commented Oct 11, 2015 at 18:05
  • 1
    Don't test the message contents. Instead test e.response['Error']['Code']. For example it will contain 'ValidationError'. I recommend printing out dir(e) to find out what's available to you in the exception object (because the boto3 docs are sorely lacking in any help on errors/exceptions). Commented Nov 12, 2015 at 0:34
  • 1
    And more specifically: if e.response['Error']['Code'] == 'EntityAlreadyExists' Commented Nov 12, 2015 at 2:33