From f9f6c47254b176c7dfaec58f05c506f5ae95db58 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 11 Aug 2023 15:19:06 +0200 Subject: [PATCH] Add error type conversions to aries-vcx-core Signed-off-by: Miroslav Kovar --- .../errors/mapping_ledger_response_parser.rs | 19 +++++++++++++++++++ aries_vcx_core/src/errors/mod.rs | 1 + indy_ledger_response_parser/src/lib.rs | 1 + 3 files changed, 21 insertions(+) create mode 100644 aries_vcx_core/src/errors/mapping_ledger_response_parser.rs diff --git a/aries_vcx_core/src/errors/mapping_ledger_response_parser.rs b/aries_vcx_core/src/errors/mapping_ledger_response_parser.rs new file mode 100644 index 0000000000..2c916d007e --- /dev/null +++ b/aries_vcx_core/src/errors/mapping_ledger_response_parser.rs @@ -0,0 +1,19 @@ +use indy_ledger_response_parser::error::LedgerResponseParserError; + +use super::error::{AriesVcxCoreError, AriesVcxCoreErrorKind}; + +impl From for AriesVcxCoreError { + fn from(err: LedgerResponseParserError) -> Self { + match &err { + LedgerResponseParserError::JsonError(err) => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::InvalidJson, err.to_string()) + } + LedgerResponseParserError::LedgerItemNotFound(item) => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::LedgerItemNotFound, err.to_string()) + } + LedgerResponseParserError::InvalidTransaction(message) => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::InvalidLedgerResponse, err.to_string()) + } + } + } +} diff --git a/aries_vcx_core/src/errors/mod.rs b/aries_vcx_core/src/errors/mod.rs index 9ec0307b4c..cc4d891250 100644 --- a/aries_vcx_core/src/errors/mod.rs +++ b/aries_vcx_core/src/errors/mod.rs @@ -6,4 +6,5 @@ mod mapping_indy_api_types; mod mapping_indyvdr; #[cfg(feature = "vdr_proxy_ledger")] mod mapping_indyvdr_proxy; +mod mapping_ledger_response_parser; mod mapping_others; diff --git a/indy_ledger_response_parser/src/lib.rs b/indy_ledger_response_parser/src/lib.rs index 28e4d56358..3420738eaf 100644 --- a/indy_ledger_response_parser/src/lib.rs +++ b/indy_ledger_response_parser/src/lib.rs @@ -4,6 +4,7 @@ extern crate serde; extern crate serde_json; mod domain; +pub mod error; pub use domain::author_agreement::GetTxnAuthorAgreementData; use domain::author_agreement::GetTxnAuthorAgreementResult;