Skip to content

Commit

Permalink
Update Unknown error to specific error message (ansible#50129)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
warusadura authored and kbreit committed Jan 11, 2019
1 parent 6526517 commit 3f3cc80
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/ansible/module_utils/redfish_utils.py
Expand Up @@ -7,6 +7,7 @@
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'}
Expand Down Expand Up @@ -35,8 +36,9 @@ def get_request(self, uri):
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):
Expand All @@ -53,8 +55,9 @@ def post_request(self, uri, pyld, hdrs):
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):
Expand All @@ -71,8 +74,9 @@ def patch_request(self, uri, pyld, hdrs):
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):
Expand All @@ -89,8 +93,9 @@ def delete_request(self, uri, pyld, hdrs):
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):
Expand Down

0 comments on commit 3f3cc80

Please sign in to comment.