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/redfish_plus.py b/lib/redfish_plus.py
index c33895a..3630cc1 100755
--- a/lib/redfish_plus.py
+++ b/lib/redfish_plus.py
@@ -120,7 +120,14 @@
max_retry = kwargs.pop("max_retry", 10)
self._max_retry = max_retry
valid_status_codes = kwargs.pop("valid_status_codes", [200])
- response = func(*args, **kwargs)
+
+ try:
+ response = func(*args, **kwargs)
+ except Exception as e:
+ error_response = type(e).__name__ + " from redfish_plus class"
+ BuiltIn().log_to_console(error_response)
+ return
+
valid_http_status_code(response.status, valid_status_codes)
return response