Update Unknown error
to specific error message (#50129)
* Update `Unknown error` to specific error message outputs the Exception received rather than just 'Unknown error' fixes: issue/49713 * Update `Unknown error` to specific error message improves the error message
This commit is contained in:
parent
3ada56e2b1
commit
44e2cbe7b7
1 changed files with 13 additions and 8 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue