diff --git a/pyghmi/exceptions.py b/pyghmi/exceptions.py index 5997b96e..097d7170 100644 --- a/pyghmi/exceptions.py +++ b/pyghmi/exceptions.py @@ -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) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 9133ccc8..dd314573 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -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]}