Skip to content

Commit

Permalink
improve rds error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
diodonfrost committed Oct 17, 2019
1 parent b95fe81 commit aa144e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions package/rds_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def stop(self, tag_key, tag_value):
self.rds.stop_db_instance(DBInstanceIdentifier=instance_id)
print("Stop rds instance {0}".format(instance_id))
except ClientError as e:
if e.response["Error"]["Code"] == "InvalidDBInstanceState":
error_code = e.response["Error"]["Code"]
if error_code == "InvalidDBInstanceState":
logging.info("%s", e)
elif error_code == "InvalidParameterCombination":
logging.info("%s", e)
else:
logging.error("Unexpected error: %s", e)
Expand Down Expand Up @@ -74,7 +77,10 @@ def start(self, tag_key, tag_value):
self.rds.start_db_instance(DBInstanceIdentifier=instance_id)
print("Start rds instance {0}".format(instance_id))
except ClientError as e:
if e.response["Error"]["Code"] == "InvalidDBInstanceState":
error_code = e.response["Error"]["Code"]
if error_code == "InvalidDBInstanceState":
logging.info("%s", e)
elif error_code == "InvalidParameterCombination":
logging.info("%s", e)
else:
logging.error("Unexpected error: %s", e)
Expand Down

0 comments on commit aa144e0

Please sign in to comment.