Can't catch the ResourceNotFoundException
See original GitHub issueDescribe the bug
Hello,
I’m creating a lambda function to store some data into a DynamoDB table. Whether the table doesn’t exists. it must be created, however the specific exception class isn’t available in the lib to import or call it.
Expected Behavior
Catch the specific exception (ResourceNotFoundException)
try:
table = dynamodb_client.Table(TABLE_NAME)
logger.info(table.table_status)
except ResourceNotFoundException:
create_table(TABLE_NAME)
Current Behavior
General expcetion catching:
try:
table = dynamodb_client.Table(TABLE_NAME)
logger.info(table.table_status)
except:
create_table(TABLE_NAME)
Reproduction Steps
The table doesn’t exists and the function is:
TABLE_NAME = 'newtable'
dynamodb_client = boto3.resource('dynamodb')
table = dynamodb_client.Table(TABLE_NAME)
logger.info(table.table_status)
and the riased error is
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the DescribeTable operation: Requested resource not found: Table: newtable not found
Possible Solution
No response
Additional Information/Context
No response
SDK version used
boto3
Environment details (OS name and version, etc.)
Ubuntu 22.04
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Symfony2 can't catch ResourceNotFoundException
Try to replace Exception by ResourceNotFoundException . And don't forget use statement: <?php namespace OOOO\AdvertisingBundle\Utilities; ...
Read more >6 Common DynamoDB Issues - Dashbird
Resource Not Found Exception. The AWS SDK can't find your table. The most common reasons for this are a typo in the table...
Read more >Error handling with DynamoDB - AWS Documentation
This section describes runtime errors and how to handle them. ... in a Java program, you can write try-catch logic to handle a...
Read more >Working with Items in DynamoDB - Amazon SDK for Java 1.x
How to retrieve (get), add, and update items in Amazon DynamoDB tables. ... putItem(table_name, item_values); } catch (ResourceNotFoundException e) ...
Read more >Cannot find resource for the request getByTitile - 404
Solved: Hi I have attempted to set up a Flow using this video : https://www.youtube.com/watch?v=T6cC65YwjSI But at the send HTTP request to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
Edit: Don’t consider this, see my next comment.
botocore.exceptions.ClientError
seems to not intercept thebotocore.errorfactory.ResourceNotFoundException
exception.I am using: