[bssl] Improve error processing when BoringSSL API fails
This cl logs Bssl the reason and library strings for all the
errors from the Bssl's error queue when an API fails and returns
the most recent error instead of the least recent one.
The logging is helpful for debugging as not all the Bssl error
codes are mapped into readable enums.
Test: atest libbssl_avf_nostd.test
Change-Id: Ifaad4acfb43461ce2794a9fd2b60ac9beb64a238
diff --git a/libs/bssl/src/util.rs b/libs/bssl/src/util.rs
index 880c85b..ddb6c6b 100644
--- a/libs/bssl/src/util.rs
+++ b/libs/bssl/src/util.rs
@@ -14,14 +14,14 @@
//! Utility functions.
-use crate::err::get_error_reason_code;
+use crate::err::process_error_queue;
use bssl_avf_error::{ApiName, Error, Result};
use log::error;
pub(crate) fn check_int_result(ret: i32, api_name: ApiName) -> Result<()> {
match ret {
1 => Ok(()),
- 0 => Err(Error::CallFailed(api_name, get_error_reason_code())),
+ 0 => Err(Error::CallFailed(api_name, process_error_queue())),
_ => {
error!(
"Received a return value ({}) other than 0 or 1 from the BoringSSL API: {:?}",
@@ -33,5 +33,5 @@
}
pub(crate) fn to_call_failed_error(api_name: ApiName) -> Error {
- Error::CallFailed(api_name, get_error_reason_code())
+ Error::CallFailed(api_name, process_error_queue())
}