mirror of
https://opendev.org/x/pyghmi
synced 2026-03-29 06:13:30 +00:00
Enhance IpmiException to carry IPMI codenumber
In some cases, an exception warrants a different handling depending on the code of the error. Have the exception carry the code up for calling code to make a decision. Change-Id: Ie7e134d3a7d99eaa1ec3a82c6f39e82dc4422ca7
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user