title: Properly catch boto3 Errors
body: <p>I am developing a django app which communicates with several Amazon Web Services.</p>
  
  <p>So far I am having trouble dealing with and catching exceptions thrown by the boto3 client. What I am doing seems unnecessarily tedious:</p>
  
  <p>Example:</p>
  
  <pre><code>client = boto3.client('sns')
  client.create_platform_endpoint(PlatformApplicationArn=SNS_APP_ARN, Token=token)
  </code></pre>
  
  <p>this might throw an <code>botocore.errorfactory.InvalidParameterException</code> if e.g. the token is bad.</p>
  
  <pre><code>client.get_endpoint_attributes(EndpointArn=endpoint_arn)
  </code></pre>
  
  <p>might throw an <code>botocore.errorfactory.NotFoundException</code>.</p>
  
  <p>First, I can't find these Errors anywhere in code, so they are probably generated somewhere. Bottom line: I can't import it and catch it as usual.</p>
  
  <p>Second, I found one way to catch the error <a href="https://stackoverflow.com/questions/42975609/how-to-capture-botocores-nosuchkey-exception">here</a> using:</p>
  
  <pre><code>try:
      # boto3 stuff
  except botocore.exceptions.ClientError as e:
      if e.response['Error']['Code'] == 'NotFound':
          # handle exception
      else:
          raise e
  </code></pre>
  
  <p>But I have to remove the <code>Exception</code> part of the error name. Seems very random and I have no clue whether I would remove the <code>Error</code> in <code>botocore.exceptions.ParamValidationError</code> if I wanted to catch that one. So it's hard to generalize.</p>
  
  <p>Another way to catch the error is using the boto3 client object I got:</p>
  
  <pre><code>try:
      # boto3 stuff
  except client.exceptions.NotFoundException as e:
      # handle exception
  </code></pre>
  
  <p>This seems the cleanest way so far. But I don't always have the boto3 client object at hand where I want to catch the error. Also I am still only trying things out, so it's mostly guess work.</p>
  
  <p>Does anybody know how boto3 errors are supposed to be handled?</p>
  
  <p>Or can point me towards some coherent documentation which mentions the errors above? Thanks</p>