diff --git a/pyghmi/exceptions.py b/pyghmi/exceptions.py index b0935fff..3fefd27d 100644 --- a/pyghmi/exceptions.py +++ b/pyghmi/exceptions.py @@ -2,6 +2,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2013 IBM Corporation +# Copyright 2015 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +24,9 @@ class PyghmiException(Exception): class IpmiException(PyghmiException): - pass + def __init__(self, text='', code=0): + super(IpmiException, self).__init__(text) + self.ipmicode = code class InvalidParameterValue(PyghmiException): diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index e90d7463..12e3b3d4 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2013 IBM Corporation +# Copyright 2015 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -363,7 +364,7 @@ class Command(object): if self._sdr.sensors[sensor].name == sensorname: rsp = self.raw_command(command=0x2d, netfn=4, data=(sensor,)) if 'error' in rsp: - raise Exception(rsp['error']) + raise exc.IpmiException(rsp['error'], rsp['code']) return self._sdr.sensors[sensor].decode_sensor_reading( rsp['data']) raise Exception('Sensor not found: ' + sensorname)