Skip to content

Commit

Permalink
Extract ohttp req from receiver::v2 error
Browse files Browse the repository at this point in the history
To be sent to the directory for sender retrieval
  • Loading branch information
DanGould committed Jan 9, 2025
1 parent f5c877a commit 0be8384
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 123 deletions.
10 changes: 10 additions & 0 deletions payjoin/src/receive/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ pub enum Error {
Server(Box<dyn error::Error>),
}

impl Error {
pub fn to_json(&self) -> String {
match self {
Self::BadRequest(e) => e.to_string(),
Self::Server(e) =>
format!("{{ \"errorCode\": \"server-error\", \"message\": \"{}\" }}", e),
}
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self {
Expand Down
Loading

0 comments on commit 0be8384

Please sign in to comment.