-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outer try catch block in Parser updateVpdKeyword API #539
base: 1110
Are you sure you want to change the base?
Outer try catch block in Parser updateVpdKeyword API #539
Conversation
This commit adds an outer try catch block in Parser::updateVpdKeyword API. Currently, this API has multiple return statements for different error scenarios, which reduces the API body's readability and modularity. In order to streamline and handle all errors in a single location, an outer try catch has been added in the API body. Test: ''' Trigger this API by calling WriteKeyword API from D-Bus: root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager WriteKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ssay\) "UTIL" "D0" 1 0 i 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 0 ''' Change-Id: I66a6c95ca0daaebb0a6f5c80e28ad4e9706d776f Signed-off-by: Souvik Roy <[email protected]>
3d5407d
to
8d22a83
Compare
This commit adds an outer try catch block in Parser::updateVpdKeyword API. Currently, this API has multiple return statements for different error scenarios, which reduces the API body's readability and modularity. In order to streamline and handle all errors in a single location, an outer try catch has been added in the API body. This commit also adds constants to define success and failure for APIs which return 0 or -1. Test: ''' Trigger this API by calling WriteKeyword API from D-Bus: root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager WriteKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ssay\) "UTIL" "D0" 1 0 i 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 0 ''' Change-Id: I66a6c95ca0daaebb0a6f5c80e28ad4e9706d776f Signed-off-by: Souvik Roy <[email protected]>
8d22a83
to
bf8679c
Compare
this is not the case. |
vpd-manager/src/parser.cpp
Outdated
|
||
// TODO: Check if revert is required when any of the writes fails. | ||
// TODO: Handle error logging | ||
return constants::FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont need this statement, as we will return at the end anyways. ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose line 69 writeKeywordOnHardware
is successful, l_bytesUpdatedOnHardware
has some value > 0, but any subsequent steps like updateVpdKeywordOnRedundantPath
fails, we have to return -1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
if (updateVpdKeywordOnRedundantPath(l_redundantFruPath, | ||
i_paramsToWriteData) < 0) | ||
std::string l_keywordIdentifier{}; | ||
if (const types::IpzData* l_ipzData = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as all the throw has sufficient information,
do we need extra log here, printing l_ex.what() is enough ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The throws do not log the Record Name and Keyword Name.
This commit adds an outer try catch block in Parser::updateVpdKeyword API. Currently, this API has multiple return statements for different error scenarios, which reduces the API body's readability and modularity. In order to streamline and handle all errors in a single location, an outer try catch has been added in the API body. This commit also adds constants to define success and failure for APIs which return 0 or -1. Test: ''' Trigger this API by calling WriteKeyword API from D-Bus: root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager WriteKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ssay\) "UTIL" "D0" 1 0 i 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 0 ''' Change-Id: I66a6c95ca0daaebb0a6f5c80e28ad4e9706d776f Signed-off-by: Souvik Roy <[email protected]>
bf8679c
to
74b9822
Compare
This commit adds an outer try catch block in Parser::updateVpdKeyword API. Currently, this API has multiple return statements for different error scenarios, which reduces the API body's readability and modularity. In order to streamline and handle all errors in a single location, an outer try catch has been added in the API body. This commit also adds constants to define success and failure for APIs which return 0 or -1. Test: ''' Trigger this API by calling WriteKeyword API from D-Bus: root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager WriteKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ssay\) "UTIL" "D0" 1 0 i 1 root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" \(ss\) "UTIL" "D0" v ay 1 0 ''' Change-Id: I66a6c95ca0daaebb0a6f5c80e28ad4e9706d776f Signed-off-by: Souvik Roy <[email protected]>
74b9822
to
8e0beac
Compare
This commit adds an outer try catch block in Parser::updateVpdKeyword API. Currently, this API has multiple return statements for different error scenarios, which reduces the API body's readability and modularity.
In order to streamline and handle all errors in a single location, an outer try catch has been added in the API body.
Test:
'''
Trigger this API by calling WriteKeyword API from D-Bus:
root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" (ss) "UTIL" "D0" v ay 1 1
root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager WriteKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" (ssay) "UTIL" "D0" 1 0 i 1
root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager ReadKeyword sv "/sys/bus/i2c/drivers/at24/8-0050/eeprom" (ss) "UTIL" "D0" v ay 1 0
'''
Change-Id: I66a6c95ca0daaebb0a6f5c80e28ad4e9706d776f