From 8408b8d0e47b46fbec7042feb5fa16e25500c6a6 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Fri, 3 Mar 2023 10:09:58 -0600 Subject: [PATCH] Add more documentation about BlockSourceError Some BlockSource implementations provide more error details. Document this in case users want to examine it further. --- lightning-block-sync/src/lib.rs | 3 +++ lightning-block-sync/src/rpc.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lightning-block-sync/src/lib.rs b/lightning-block-sync/src/lib.rs index 189a68be0..0a7c65514 100644 --- a/lightning-block-sync/src/lib.rs +++ b/lightning-block-sync/src/lib.rs @@ -132,6 +132,9 @@ impl BlockSourceError { } /// Converts the error into the underlying error. + /// + /// May contain an [`std::io::Error`] from the [`BlockSource`]. See implementations for further + /// details, if any. pub fn into_inner(self) -> Box { self.error } diff --git a/lightning-block-sync/src/rpc.rs b/lightning-block-sync/src/rpc.rs index 6b4397a6b..e1dc43c8f 100644 --- a/lightning-block-sync/src/rpc.rs +++ b/lightning-block-sync/src/rpc.rs @@ -35,6 +35,9 @@ impl fmt::Display for RpcError { impl Error for RpcError {} /// A simple RPC client for calling methods using HTTP `POST`. +/// +/// Implements [`BlockSource`] and may return an `Err` containing [`RpcError`]. See +/// [`RpcClient::call_method`] for details. pub struct RpcClient { basic_auth: String, endpoint: HttpEndpoint, @@ -57,6 +60,9 @@ impl RpcClient { } /// Calls a method with the response encoded in JSON format and interpreted as type `T`. + /// + /// When an `Err` is returned, [`std::io::Error::into_inner`] may contain an [`RpcError`] if + /// [`std::io::Error::kind`] is [`std::io::ErrorKind::Other`]. pub async fn call_method(&self, method: &str, params: &[serde_json::Value]) -> std::io::Result where JsonResponse: TryFrom, Error = std::io::Error> + TryInto { let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port()); -- 2.39.5