mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
fail if transaction submit has failed (#1584)
This commit is contained in:
committed by
Bastian Köcher
parent
e534e90193
commit
0f79d1e86e
@@ -416,7 +416,7 @@ pub async fn run<P: MessageRace, SC: SourceClient<P>, TC: TargetClient<P>>(
|
||||
&mut target_go_offline_future,
|
||||
async_std::task::sleep,
|
||||
|| format!("Error submitting proof {}", P::target_name()),
|
||||
).fail_if_connection_error(FailedClient::Target)?;
|
||||
).fail_if_error(FailedClient::Target).map(|_| true)?;
|
||||
},
|
||||
target_transaction_status = target_tx_tracker => {
|
||||
if target_transaction_status == TrackedTransactionStatus::Lost {
|
||||
|
||||
@@ -236,6 +236,16 @@ impl ProcessFutureResult {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `Ok(())` if future has succeeded.
|
||||
/// Returns `Err(failed_client)` otherwise.
|
||||
pub fn fail_if_error(self, failed_client: FailedClient) -> Result<(), FailedClient> {
|
||||
if self.is_ok() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(failed_client)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns Ok(true) if future has succeeded.
|
||||
/// Returns Ok(false) if future has failed with non-connection error.
|
||||
/// Returns Err if future is `ConnectionFailed`.
|
||||
|
||||
Reference in New Issue
Block a user