Skip to content

Commit

Permalink
Print supported Vs on version-unsupported error
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Jan 7, 2024
1 parent 2d86512 commit 895fe29
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions payjoin/src/send/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl Display for WellKnownError {
match self {
Self::Unavailable(_) => write!(f, "The payjoin endpoint is not available for now."),
Self::NotEnoughMoney(_) => write!(f, "The receiver added some inputs but could not bump the fee of the payjoin proposal."),
Self::VersionUnsupported(_, _) => write!(f, "This version of payjoin is not supported."),
Self::VersionUnsupported(_, v) => write!(f, "This version of payjoin is not supported. Use version {:?}.", v),
Self::OriginalPsbtRejected(_) => write!(f, "The receiver rejected the original PSBT."),
}
}
Expand All @@ -392,14 +392,16 @@ mod tests {

#[test]
fn test_parse_json() {
let known_str_error =
r#"{"errorCode":"version-unsupported", "message":"custom message here"}"#;
let known_str_error = r#"{"errorCode":"version-unsupported", "message":"custom message here", "supported": [1, 2]}"#;
let error = ResponseError::from_str(known_str_error);
match error {
ResponseError::WellKnown(e) => {
assert_eq!(e.error_code(), "version-unsupported");
assert_eq!(e.message(), "custom message here");
assert_eq!(e.to_string(), "This version of payjoin is not supported.");
assert_eq!(
e.to_string(),
"This version of payjoin is not supported. Use version [1, 2]."
);
}
_ => panic!("Expected WellKnown error"),
};
Expand Down

0 comments on commit 895fe29

Please sign in to comment.