Skip to content

Commit 4f6cc3d

Browse files
committed
specify exact errors in robust provider error docs
1 parent 07101ff commit 4f6cc3d

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

src/robust_provider/provider.rs

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ impl<N: Network> RobustProvider<N> {
115115
///
116116
/// # Errors
117117
///
118-
/// See [retry errors](#retry-errors).
118+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
119+
/// by the last provider attempted on the last retry.
120+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
121+
/// `call_timeout`).
122+
/// * [`Error::BlockNotFound`] - if the block with the specified hash was not found on-chain.
119123
pub async fn get_block_by_number(
120124
&self,
121125
number: BlockNumberOrTag,
@@ -140,7 +144,11 @@ impl<N: Network> RobustProvider<N> {
140144
///
141145
/// # Errors
142146
///
143-
/// See [retry errors](#retry-errors).
147+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
148+
/// by the last provider attempted on the last retry.
149+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
150+
/// `call_timeout`).
151+
/// * [`Error::BlockNotFound`] - if the block with the specified hash was not found on-chain.
144152
pub async fn get_block(&self, id: BlockId) -> Result<N::BlockResponse, Error> {
145153
info!("eth_getBlock called");
146154
let result = self
@@ -161,7 +169,10 @@ impl<N: Network> RobustProvider<N> {
161169
///
162170
/// # Errors
163171
///
164-
/// See [retry errors](#retry-errors).
172+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
173+
/// by the last provider attempted on the last retry.
174+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
175+
/// `call_timeout`).
165176
pub async fn get_block_number(&self) -> Result<BlockNumber, Error> {
166177
info!("eth_getBlockNumber called");
167178
let result = self
@@ -187,7 +198,11 @@ impl<N: Network> RobustProvider<N> {
187198
///
188199
/// # Errors
189200
///
190-
/// See [retry errors](#retry-errors).
201+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
202+
/// by the last provider attempted on the last retry.
203+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
204+
/// `call_timeout`).
205+
/// * [`Error::BlockNotFound`] - if the block with the specified hash was not found on-chain.
191206
pub async fn get_block_number_by_id(&self, block_id: BlockId) -> Result<BlockNumber, Error> {
192207
info!("get_block_number_by_id called");
193208
let result = self
@@ -214,7 +229,10 @@ impl<N: Network> RobustProvider<N> {
214229
///
215230
/// # Errors
216231
///
217-
/// See [retry errors](#retry-errors).
232+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
233+
/// by the last provider attempted on the last retry.
234+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
235+
/// `call_timeout`).
218236
pub async fn get_latest_confirmed(&self, confirmations: u64) -> Result<u64, Error> {
219237
info!("get_latest_confirmed called with confirmations={}", confirmations);
220238
let latest_block = self.get_block_number().await?;
@@ -228,7 +246,11 @@ impl<N: Network> RobustProvider<N> {
228246
///
229247
/// # Errors
230248
///
231-
/// See [retry errors](#retry-errors).
249+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
250+
/// by the last provider attempted on the last retry.
251+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
252+
/// `call_timeout`).
253+
/// * [`Error::BlockNotFound`] - if the block with the specified hash was not found on-chain.
232254
pub async fn get_block_by_hash(&self, hash: BlockHash) -> Result<N::BlockResponse, Error> {
233255
info!("eth_getBlockByHash called");
234256
let result = self
@@ -250,7 +272,10 @@ impl<N: Network> RobustProvider<N> {
250272
///
251273
/// # Errors
252274
///
253-
/// See [retry errors](#retry-errors).
275+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
276+
/// by the last provider attempted on the last retry.
277+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
278+
/// `call_timeout`).
254279
pub async fn get_logs(&self, filter: &Filter) -> Result<Vec<Log>, Error> {
255280
info!("eth_getLogs called");
256281
let result = self
@@ -277,7 +302,10 @@ impl<N: Network> RobustProvider<N> {
277302
///
278303
/// # Errors
279304
///
280-
/// see [retry errors](#retry-errors).
305+
/// * [`Error::RpcError`] - if no fallback providers succeeded; contains the last error returned
306+
/// by the last provider attempted on the last retry.
307+
/// * [`Error::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
308+
/// `call_timeout`).
281309
pub async fn subscribe_blocks(&self) -> Result<RobustSubscription<N>, Error> {
282310
info!("eth_subscribe called");
283311
let subscription = self
@@ -300,7 +328,7 @@ impl<N: Network> RobustProvider<N> {
300328

301329
/// Execute `operation` with exponential backoff and a total timeout.
302330
///
303-
/// Wraps the retry logic with `tokio::time::timeout(self.call_timeout, ...)` so
331+
/// Wraps the retry logic with [`tokio::time::timeout`] so
304332
/// the entire operation (including time spent inside the RPC call) cannot exceed
305333
/// `call_timeout`.
306334
///
@@ -310,14 +338,11 @@ impl<N: Network> RobustProvider<N> {
310338
/// If `require_pubsub` is true, providers that don't support pubsub will be skipped.
311339
///
312340
/// # Errors
313-
/// <a name="retry-errors"></a>
314-
///
315-
/// * Returns [`RpcError<TransportErrorKind>`] with message "total operation timeout exceeded
316-
/// and all fallback providers failed" if the overall timeout elapses and no fallback
317-
/// providers succeed.
318-
/// * Returns [`RpcError::Transport(TransportErrorKind::PubsubUnavailable)`] if `require_pubsub`
319-
/// is true and all providers don't support pubsub.
320-
/// * Propagates any [`RpcError<TransportErrorKind>`] from the underlying retries.
341+
///
342+
/// * [`CoreError::RpcError`] - if no fallback providers succeeded; contains the last error
343+
/// returned by the last provider attempted on the last retry.
344+
/// * [`CoreError::Timeout`] - if the overall operation timeout elapses (i.e. exceeds
345+
/// `call_timeout`).
321346
pub(crate) async fn try_operation_with_failover<T: Debug, F, Fut>(
322347
&self,
323348
operation: F,

0 commit comments

Comments
 (0)