From aa144e0f84cb3931087904b14ceeec7adc5d71eb Mon Sep 17 00:00:00 2001 From: diodonfrost Date: Thu, 17 Oct 2019 20:07:00 +0200 Subject: [PATCH] improve rds error catching --- package/rds_handler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/rds_handler.py b/package/rds_handler.py index b12ff283..89f19f7f 100644 --- a/package/rds_handler.py +++ b/package/rds_handler.py @@ -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) @@ -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)