mirror of
https://opendev.org/x/pyghmi
synced 2025-10-26 08:55:20 +00:00
Provide better messages when redfish provides
This provides a more informative behavior in the clients. Change-Id: I7cecc39c3928aac6ee2d9b86ed53159dcdf3dde5
This commit is contained in:
@@ -29,6 +29,10 @@ class IpmiException(PyghmiException):
|
||||
self.ipmicode = code
|
||||
|
||||
|
||||
class RedfishError(PyghmiException):
|
||||
pass
|
||||
|
||||
|
||||
class UnrecognizedCertificate(Exception):
|
||||
def __init__(self, text='', certdata=None):
|
||||
super(UnrecognizedCertificate, self).__init__(text)
|
||||
|
||||
@@ -312,7 +312,15 @@ class Command(object):
|
||||
if 'If-Match' in wc.stdheaders:
|
||||
del wc.stdheaders['If-Match']
|
||||
if res[1] < 200 or res[1] >= 300:
|
||||
raise exc.PyghmiException(res[0])
|
||||
try:
|
||||
info = json.loads(res[0])
|
||||
errmsg = [
|
||||
x['Message'] for x in info.get('error', {}).get(
|
||||
'@Message.ExtendedInfo', {})]
|
||||
errmsg = ','.join(errmsg)
|
||||
raise exc.RedfishError(errmsg)
|
||||
except (ValueError, KeyError):
|
||||
raise exc.PyghmiException(res[0])
|
||||
if payload is None and method is None:
|
||||
self._urlcache[url] = {'contents': res[0],
|
||||
'vintage': os.times()[4]}
|
||||
|
||||
Reference in New Issue
Block a user