python boto3 exception handling

Solutions on MaxInterview for python boto3 exception handling by the best coders in the world

showing results for - "python boto3 exception handling"
Erika
18 Nov 2017
1import botocore
2import boto3
3import logging
4
5# Set up our logger
6logging.basicConfig(level=logging.INFO)
7logger = logging.getLogger()
8
9client = boto3.client('kinesis')
10
11try:
12    logger.info('Calling DescribeStream API on myDataStream')
13    client.describe_stream(StreamName='myDataStream')
14
15except botocore.exceptions.ClientError as error:
16    if error.response['Error']['Code'] == 'LimitExceededException':
17        logger.warn('API call limit exceeded; backing off and retrying...')
18    else:
19        raise error
20