diff --git a/lib/ansible/module_utils/redfish_utils.py b/lib/ansible/module_utils/redfish_utils.py index a1fb9325c80..a3a3d389320 100644 --- a/lib/ansible/module_utils/redfish_utils.py +++ b/lib/ansible/module_utils/redfish_utils.py @@ -7,6 +7,7 @@ __metaclass__ = type import json import re from ansible.module_utils.urls import open_url +from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError HEADERS = {'content-type': 'application/json'} @@ -35,8 +36,9 @@ class RedfishUtils(object): except URLError as e: return {'ret': False, 'msg': "URL Error: %s" % e.reason} # Almost all errors should be caught above, but just in case - except Exception: - return {'ret': False, 'msg': "Unknown error"} + except Exception as e: + return {'ret': False, + 'msg': 'Failed GET operation against Redfish API server: %s' % to_text(e)} return {'ret': True, 'data': data} def post_request(self, uri, pyld, hdrs): @@ -53,8 +55,9 @@ class RedfishUtils(object): except URLError as e: return {'ret': False, 'msg': "URL Error: %s" % e.reason} # Almost all errors should be caught above, but just in case - except Exception: - return {'ret': False, 'msg': "Unknown error"} + except Exception as e: + return {'ret': False, + 'msg': 'Failed POST operation against Redfish API server: %s' % to_text(e)} return {'ret': True, 'resp': resp} def patch_request(self, uri, pyld, hdrs): @@ -71,8 +74,9 @@ class RedfishUtils(object): except URLError as e: return {'ret': False, 'msg': "URL Error: %s" % e.reason} # Almost all errors should be caught above, but just in case - except Exception: - return {'ret': False, 'msg': "Unknown error"} + except Exception as e: + return {'ret': False, + 'msg': 'Failed PATCH operation against Redfish API server: %s' % to_text(e)} return {'ret': True, 'resp': resp} def delete_request(self, uri, pyld, hdrs): @@ -89,8 +93,9 @@ class RedfishUtils(object): except URLError as e: return {'ret': False, 'msg': "URL Error: %s" % e.reason} # Almost all errors should be caught above, but just in case - except Exception: - return {'ret': False, 'msg': "Unknown error"} + except Exception as e: + return {'ret': False, + 'msg': 'Failed DELETE operation against Redfish API server: %s' % to_text(e)} return {'ret': True, 'resp': resp} def _init_session(self):