From e3f5a2a90cde10013ea2d1183bdb51e6f3dfacfa Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 11 Aug 2023 15:48:49 +0200 Subject: [PATCH] Map error in parse_response Signed-off-by: Miroslav Kovar --- indy_ledger_response_parser/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/indy_ledger_response_parser/src/lib.rs b/indy_ledger_response_parser/src/lib.rs index 3420738eaf..35b450accc 100644 --- a/indy_ledger_response_parser/src/lib.rs +++ b/indy_ledger_response_parser/src/lib.rs @@ -238,7 +238,12 @@ impl ResponseParser { where T: DeserializeOwned + ReplyType + ::std::fmt::Debug, { - let message: Message = serde_json::from_str(response)?; + // TODO: Distinguish between not found and unexpected response format + let message: Message = serde_json::from_str(response).map_err(|_| { + LedgerResponseParserError::LedgerItemNotFound( + "Structure doesn't correspond to type. Most probably not found", + ) + })?; match message { Message::Reject(response) | Message::ReqNACK(response) => {