From 576832e4c9224caaed8826f83e3b12a430e68277 Mon Sep 17 00:00:00 2001 From: Kim Johansson Date: Fri, 27 Mar 2015 10:46:01 +0100 Subject: Always define error before using it When the error reason is "Forbidden", the code throws a Python exception rather than simply outputting the exception reason. It's not nice to throw a Python exception when all the info to display a proper message is available. --- plugins/inventory/ec2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index 5f7bd061d7..e93df1053d 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -382,6 +382,8 @@ class Ec2Inventory(object): for instance in instances: self.add_rds_instance(instance, region) except boto.exception.BotoServerError, e: + error = e.reason + if e.error_code == 'AuthFailure': error = self.get_auth_error_message() if not e.reason == "Forbidden": -- cgit v1.2.1