Skip to content

Commit

Permalink
Expand error message on invalid swap state (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 authored Apr 29, 2024
1 parent 47a8dde commit 021d28c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/ls-sdk-core/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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}",
));
}
}
Expand Down

0 comments on commit 021d28c

Please sign in to comment.