Expand error message on invalid swap state (#112)

This commit is contained in:
ok300
2024-04-29 11:03:39 +00:00
committed by GitHub
parent 47a8dde47d
commit 021d28c947

View File

@@ -124,10 +124,10 @@ impl Wallet {
.swap_status(SwapStatusRequest { id: id.clone() })
.map_err(|e| anyhow!("Failed to fetch swap status for ID {id}: {e:?}"))?;
let swap_state = status_response
.status
let status = status_response.status;
let swap_state = status
.parse::<SubSwapStates>()
.map_err(|_| anyhow!("Invalid swap state received for swap {id}"))?;
.map_err(|_| anyhow!("Invalid swap state received for swap {id}: {status}",))?;
match swap_state {
SubSwapStates::SwapExpired => {
@@ -140,8 +140,7 @@ impl Wallet {
SubSwapStates::TransactionMempool | SubSwapStates::TransactionConfirmed => {}
_ => {
return Err(anyhow!(
"Cannot claim swap {id}: invoice not paid yet. Swap state: {}",
swap_state.to_string()
"Cannot claim swap {id}: invoice not paid yet. Swap state: {status}",
));
}
}