Skip to content

Commit

Permalink
Remove failure crate from libvcx
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed Dec 5, 2022
1 parent f1b5bb7 commit 32956f7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion agency_client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,20 @@ impl AgencyClientError {
{
AgencyClientError {
msg: msg.to_string(),
kind
kind,
}
}

pub fn find_root_cause(&self) -> String {
let mut current = self.source();
while let Some(cause) = current {
if cause.source().is_none() { return cause.to_string() }
current = cause.source();
}
self.to_string()
}


pub fn kind(&self) -> AgencyClientErrorKind {
self.kind
}
Expand Down
9 changes: 9 additions & 0 deletions aries_vcx/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ impl VcxError {
}
}

pub fn find_root_cause(&self) -> String {
let mut current = self.source();
while let Some(cause) = current {
if cause.source().is_none() { return cause.to_string() }
current = cause.source();
}
self.to_string()
}

pub fn kind(&self) -> VcxErrorKind {
self.kind
}
Expand Down
7 changes: 5 additions & 2 deletions aries_vcx/src/indy/signing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vdrtools::{Locator, KeyInfo};
use vdrtools::Locator;

use vdrtools::WalletHandle;

Expand Down Expand Up @@ -94,7 +94,10 @@ pub async fn unpack_message(wallet_handle: WalletHandle, msg: &[u8]) -> VcxResul
Ok(res)
}

#[cfg(feature = "test_utils")]
pub async fn create_key(wallet_handle: WalletHandle, seed: Option<&str>) -> VcxResult<String> {
use vdrtools::KeyInfo;

let res = Locator::instance()
.crypto_controller
.create_key(
Expand All @@ -106,4 +109,4 @@ pub async fn create_key(wallet_handle: WalletHandle, seed: Option<&str>) -> VcxR
).await?;

Ok(res)
}
}
1 change: 0 additions & 1 deletion libvcx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ base64 = "0.10"
futures = { version = "0.3", default-features = false }
tokio = { version = "1.15.0", features = ["rt-multi-thread"] }
uuid = {version = "0.7.1", default-features = false, features = ["v4"]}
failure = "0.1.8"
aries-vcx = { path = "../aries_vcx" }

[target.'cfg(target_os = "android")'.dependencies]
Expand Down
11 changes: 6 additions & 5 deletions libvcx/src/api_lib/utils/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::ffi::CString;
use std::ptr;

use aries_vcx::agency_client::error::AgencyClientError;
use failure::Fail;
use libc::c_char;

use crate::api_lib::utils::cstring::CStringUtils;
Expand All @@ -26,8 +25,9 @@ pub fn set_current_error_agency(err: &AgencyClientError) {
let error_json = json!({
"error": err.kind().to_string(),
"message": err.to_string(),
"cause": <dyn Fail>::find_root_cause(err).to_string(),
"backtrace": err.backtrace().map(|bt| bt.to_string())
"cause": err.find_root_cause(),
// TODO: Put back once https://github.com/rust-lang/rust/issues/99301 is stabilized
// "backtrace": err.backtrace()
})
.to_string();
error.replace(Some(CStringUtils::string_to_cstring(error_json)));
Expand All @@ -42,8 +42,9 @@ pub fn set_current_error_vcx(err: &VcxError) {
let error_json = json!({
"error": err.kind().to_string(),
"message": err.to_string(),
"cause": <dyn Fail>::find_root_cause(err).to_string(),
"backtrace": err.backtrace().map(|bt| bt.to_string())
"cause": err.find_root_cause(),
// TODO: Put back once https://github.com/rust-lang/rust/issues/99301 is stabilized
// "backtrace": err.backtrace()
})
.to_string();
error.replace(Some(CStringUtils::string_to_cstring(error_json)));
Expand Down

0 comments on commit 32956f7

Please sign in to comment.