Skip to content

Commit ac7df5c

Browse files
committed
improve faucet error handling
1 parent 644638f commit ac7df5c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/handler/faucet.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,21 @@ pub async fn request_transfer(
205205

206206
transfer_tx_builder.tx.memo = Some("Transfer from faucet".to_string().as_bytes().to_vec());
207207

208-
let (mut transfer_tx, signing_data) = transfer_tx_builder
208+
let tx_result = transfer_tx_builder
209209
.build(&*state.sdk)
210-
.await
211-
.expect("unable to build transfer");
210+
.await;
211+
212+
let (mut transfer_tx, signing_data) = match tx_result {
213+
Ok(res) => res,
214+
Err(e) => {
215+
return Err(FaucetError::SdkError(format!(
216+
"unable to build transfer tx: {}",
217+
e
218+
))
219+
.into())
220+
}
221+
};
222+
212223
state
213224
.sdk
214225
.sign(

0 commit comments

Comments
 (0)