I am getting this exception (printing the class for debugging) when running my code:
An error occurred (DBInstanceNotFound) when calling the DescribeDBInstances operation: DBInstance <instance name> not found.
<class 'botocore.errorfactory.DBInstanceNotFoundFault'>
I would like to handle the exception properly like this:
from botocore.exceptions import DBInstanceNotFoundFault
from botocore.errorfactory import DBInstanceNotFoundFault
try:
<fetch info about db instance>
except DBInstanceNotFoundFault as e:
<handle error>
Unfortunately DBInstanceNotFoundFault does neither exist in botocore.exceptions nor in botocore.errorfactory. I've cloned boto3 as well as botocore and grep'd for DBInstanceNotFoundFault but just can't find it.
How can I import it?
For boto3 exceptions, you don't actually import the error - rather you access it through the client. Check this out: https://github.com/boto/boto3/issues/1195#issuecomment-317108970
import boto3
rds = boto3.client('rds')
try:
...
except rds.exceptions.DBInstanceNotFoundFault:
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With