From 3d2ab0438970d8c87d4dd99f6418341d5bc8ab93 Mon Sep 17 00:00:00 2001 From: Patrik Stas Date: Tue, 20 Dec 2022 23:16:15 +0100 Subject: [PATCH] Fix compile errors, fix failing test Signed-off-by: Patrik Stas --- libvcx/src/api_lib/api_handle/credential_def.rs | 3 ++- libvcx/src/api_lib/utils/ccallback.rs | 2 +- libvcx/src/api_lib/utils/cstring.rs | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libvcx/src/api_lib/api_handle/credential_def.rs b/libvcx/src/api_lib/api_handle/credential_def.rs index 60ddf2a01b..e48110a6d6 100644 --- a/libvcx/src/api_lib/api_handle/credential_def.rs +++ b/libvcx/src/api_lib/api_handle/credential_def.rs @@ -55,7 +55,8 @@ pub fn to_string(handle: u32) -> LibvcxResult { } pub fn from_string(data: &str) -> LibvcxResult { - let cred_def: CredentialDef = CredentialDef::from_string(data)?; + let cred_def: CredentialDef = CredentialDef::from_string(data) + .or_else(|e| Err(ErrorLibvcx::from_msg(ErrorKindLibvcx::CreateCredDef, e.to_string())))?; CREDENTIALDEF_MAP.add(cred_def) } diff --git a/libvcx/src/api_lib/utils/ccallback.rs b/libvcx/src/api_lib/utils/ccallback.rs index 25120a99ca..9d85d09c0d 100644 --- a/libvcx/src/api_lib/utils/ccallback.rs +++ b/libvcx/src/api_lib/utils/ccallback.rs @@ -3,7 +3,7 @@ macro_rules! check_useful_c_callback { let $x = match $x { Some($x) => $x, None => { - let err = LibvcxError::from_msg($e, "Invalid callback has been passed"); + let err = ErrorLibvcx::from_msg($e, "Invalid callback has been passed"); set_current_error_vcx(&err); return err.into(); } diff --git a/libvcx/src/api_lib/utils/cstring.rs b/libvcx/src/api_lib/utils/cstring.rs index 664efb3241..e23285d021 100644 --- a/libvcx/src/api_lib/utils/cstring.rs +++ b/libvcx/src/api_lib/utils/cstring.rs @@ -41,14 +41,14 @@ macro_rules! check_useful_c_str { let $x = match CStringUtils::c_str_to_string($x) { Ok(Some(val)) => val, _ => { - let err = LibvcxError::from_msg($e, "Invalid pointer has been passed"); + let err = ErrorLibvcx::from_msg($e, "Invalid pointer has been passed"); set_current_error_vcx(&err); return err.into(); } }; if $x.is_empty() { - let err = LibvcxError::from_msg($e, "Empty string has been passed"); + let err = ErrorLibvcx::from_msg($e, "Empty string has been passed"); set_current_error_vcx(&err); return err.into(); } @@ -60,7 +60,7 @@ macro_rules! check_useful_opt_c_str { let $x = match CStringUtils::c_str_to_string($x) { Ok(opt_val) => opt_val, Err(_) => { - let err = LibvcxError::from_msg($e, "Invalid pointer has been passed"); + let err = ErrorLibvcx::from_msg($e, "Invalid pointer has been passed"); set_current_error_vcx(&err); return err.into(); } @@ -71,12 +71,12 @@ macro_rules! check_useful_opt_c_str { macro_rules! check_useful_c_byte_array { ($ptr:ident, $len:expr, $err1:expr, $err2:expr) => { if $ptr.is_null() { - let err = LibvcxError::from_msg($err1, "Invalid pointer has been passed"); + let err = ErrorLibvcx::from_msg($err1, "Invalid pointer has been passed"); set_current_error_vcx(&err); return err.into(); } if $len <= 0 { - let err = LibvcxError::from_msg($err2, "Array length must be greater than 0"); + let err = ErrorLibvcx::from_msg($err2, "Array length must be greater than 0"); set_current_error_vcx(&err); return err.into(); }