From c8824764bcce542e0d94889eacd73a86effde606 Mon Sep 17 00:00:00 2001 From: Milos Stankovic <82043364+morph-dev@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:38:59 +0200 Subject: [PATCH] fix: fallback to custom error if we can't parse ContentNotFound error --- rpc/src/fetch.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rpc/src/fetch.rs b/rpc/src/fetch.rs index 0585a242c..49d731501 100644 --- a/rpc/src/fetch.rs +++ b/rpc/src/fetch.rs @@ -35,16 +35,11 @@ where Ok(result) => from_value(result), Err(msg) => { if msg.contains("Unable to locate content on the network") { - let error: ContentNotFoundJsonError = serde_json::from_str(&msg).map_err(|e| { - RpcServeError::Message(format!( - "Failed to parse error message from {} subnetwork: {e:?}", - TEndpoint::subnetwork(), - )) - })?; - Err(error.into()) - } else { - Err(RpcServeError::Message(msg)) + if let Ok(err) = serde_json::from_str::(&msg) { + return Err(err.into()); + } } + Err(RpcServeError::Message(msg)) } } }