Skip to content

Commit

Permalink
fix: fallback to custom error if we can't parse ContentNotFound error
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev committed Dec 7, 2024
1 parent 3db8488 commit c882476
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions rpc/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ContentNotFoundJsonError>(&msg) {
return Err(err.into());
}
}
Err(RpcServeError::Message(msg))
}
}
}

0 comments on commit c882476

Please sign in to comment.