Handle exceptions when there are connection errors
Changes:
- Added try except handling in a key location to
suppress noisy traceback python dumping on the
console.
- Add code to mask password in the console log
Tested:
- When failed to connect to the server when it is not
responsive.
- Wrong password causing the connection to fail.
- Wrong HTTPS port to cause connection failure
Change-Id: I27bb4e2fe4489ad742b7d9ebacd09a8f7ced4fa0
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index a7a70c4..1fe66c3 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -56,6 +56,14 @@
gp.lprint_var(except_type)
gp.lprint_varx("except_value", str(except_value))
raise (get_exception)
+ except AttributeError as e:
+ BuiltIn().log_to_console(
+ "AttributeError: Error response from server"
+ )
+ except Exception as e:
+ error_response = type(e).__name__ + " from bmc_redfish class"
+ BuiltIn().log_to_console(error_response)
+
BuiltIn().set_global_variable("${REDFISH_SUPPORTED}", self.__inited__)
BuiltIn().set_global_variable("${REDFISH_REST_SUPPORTED}", True)