You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am moving the discussion at #2723 here. It seems like those discussions might not be seen.
I have this simplified test code:
import awswrangler
import botocore
query = f"SELECT * FROM table_that_does_not_exist"
print(f"Executing statement: {query}\n...", flush=True)
response = awswrangler.dynamodb.execute_statement(query)
try:
# This throws: botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the ExecuteStatement operation: Requested resource not found
print(list(response))
except botocore.errorfactory.ResourceNotFoundException:
# This throws AttributeError: module 'botocore.errorfactory' has no attribute 'ResourceNotFoundException'
print("Exception successfully caught.")
How can I properly catch the botocore.errorfactory.ValidationException error?
Here is the beset that I have been able to come up with:
import awswrangler
from botocore.exceptions import ClientError
query = f"SELECT * FROM table_that_does_not_exist"
print(f"Executing statement: {query}\n...", flush=True)
response = awswrangler.dynamodb.execute_statement(query)
try:
# This throws: botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the ExecuteStatement operation: Requested resource not found
print(list(response))
except ClientError as e:
if e.response['Error']['Code'] == 'ResourceNotFoundException':
print("Exception successfully caught.")
Is this the best way to catch botocore exceptions when using awswrangler?
The text was updated successfully, but these errors were encountered:
but to me, it seems silly to create a boto3 session just to catch exceptions. I assume awswrangler is using a boto3 session. Is it accessible for us to use?
I am moving the discussion at #2723 here. It seems like those discussions might not be seen.
I have this simplified test code:
How can I properly catch the
botocore.errorfactory.ValidationException
error?Here is the beset that I have been able to come up with:
Is this the best way to catch
botocore
exceptions when usingawswrangler
?The text was updated successfully, but these errors were encountered: