Skip to content

Commit 8408b8d

Browse files
committed
Add more documentation about BlockSourceError
Some BlockSource implementations provide more error details. Document this in case users want to examine it further.
1 parent fbe9f47 commit 8408b8d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lightning-block-sync/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ impl BlockSourceError {
132132
}
133133

134134
/// Converts the error into the underlying error.
135+
///
136+
/// May contain an [`std::io::Error`] from the [`BlockSource`]. See implementations for further
137+
/// details, if any.
135138
pub fn into_inner(self) -> Box<dyn std::error::Error + Send + Sync> {
136139
self.error
137140
}

lightning-block-sync/src/rpc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ impl fmt::Display for RpcError {
3535
impl Error for RpcError {}
3636

3737
/// A simple RPC client for calling methods using HTTP `POST`.
38+
///
39+
/// Implements [`BlockSource`] and may return an `Err` containing [`RpcError`]. See
40+
/// [`RpcClient::call_method`] for details.
3841
pub struct RpcClient {
3942
basic_auth: String,
4043
endpoint: HttpEndpoint,
@@ -57,6 +60,9 @@ impl RpcClient {
5760
}
5861

5962
/// Calls a method with the response encoded in JSON format and interpreted as type `T`.
63+
///
64+
/// When an `Err` is returned, [`std::io::Error::into_inner`] may contain an [`RpcError`] if
65+
/// [`std::io::Error::kind`] is [`std::io::ErrorKind::Other`].
6066
pub async fn call_method<T>(&self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T>
6167
where JsonResponse: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
6268
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());

0 commit comments

Comments
 (0)