Make NOT_FOUND errors silent for VPN profiles and keys.
There are several errors printed in keystore2 startup due to above NOT_FOUND errors. Test: check keystore2 startup logs. Change-Id: Icdf553b141cda09f371f7eb83b273444130fe3e7
This commit is contained in:
parent
230b4dcc3a
commit
e1d1bbd47f
2 changed files with 17 additions and 7 deletions
|
@ -140,7 +140,7 @@ pub fn map_binder_status_code<T>(r: Result<T, StatusCode>) -> Result<T, Error> {
|
|||
/// This function should be used by Keystore service calls to translate error conditions
|
||||
/// into service specific exceptions.
|
||||
///
|
||||
/// All error conditions get logged by this function.
|
||||
/// All error conditions get logged by this function, except for KEY_NOT_FOUND error.
|
||||
///
|
||||
/// All `Error::Rc(x)` and `Error::Km(x)` variants get mapped onto a service specific error
|
||||
/// code of x. This is possible because KeyMint `ErrorCode` errors are always negative and
|
||||
|
@ -174,7 +174,13 @@ where
|
|||
map_err_with(
|
||||
result,
|
||||
|e| {
|
||||
// Make the key not found errors silent.
|
||||
if !matches!(
|
||||
e.root_cause().downcast_ref::<Error>(),
|
||||
Some(Error::Rc(ResponseCode::KEY_NOT_FOUND))
|
||||
) {
|
||||
log::error!("{:?}", e);
|
||||
}
|
||||
e
|
||||
},
|
||||
handle_ok,
|
||||
|
|
|
@ -173,7 +173,7 @@ impl Error {
|
|||
/// This function should be used by vpnprofilestore service calls to translate error conditions
|
||||
/// into service specific exceptions.
|
||||
///
|
||||
/// All error conditions get logged by this function.
|
||||
/// All error conditions get logged by this function, except for ERROR_PROFILE_NOT_FOUND error.
|
||||
///
|
||||
/// `Error::Error(x)` variants get mapped onto a service specific error code of `x`.
|
||||
///
|
||||
|
@ -188,12 +188,16 @@ where
|
|||
{
|
||||
result.map_or_else(
|
||||
|e| {
|
||||
log::error!("{:?}", e);
|
||||
let root_cause = e.root_cause();
|
||||
let rc = match root_cause.downcast_ref::<Error>() {
|
||||
Some(Error::Error(e)) => *e,
|
||||
Some(Error::Binder(_, _)) | None => ERROR_SYSTEM_ERROR,
|
||||
let (rc, log_error) = match root_cause.downcast_ref::<Error>() {
|
||||
// Make the profile not found errors silent.
|
||||
Some(Error::Error(ERROR_PROFILE_NOT_FOUND)) => (ERROR_PROFILE_NOT_FOUND, false),
|
||||
Some(Error::Error(e)) => (*e, true),
|
||||
Some(Error::Binder(_, _)) | None => (ERROR_SYSTEM_ERROR, true),
|
||||
};
|
||||
if log_error {
|
||||
log::error!("{:?}", e);
|
||||
}
|
||||
Err(BinderStatus::new_service_specific_error(rc, None))
|
||||
},
|
||||
handle_ok,
|
||||
|
|
Loading…
Reference in a new issue