Skip to content

Commit 91f3e15

Browse files
authored
Remove FinalizeResponseError in favor of using FinalizedError (payjoin#764)
After payjoin#745 I realized we can go further and completely remove the `FinalizeResponseError` in favor of using `FinalizedError` which already has access to `DirectoryResponse` errors.
2 parents ab191b4 + 911154e commit 91f3e15

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

payjoin/src/send/multiparty/error.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,3 @@ impl std::error::Error for FinalizedError {
7979
}
8080
}
8181
}
82-
83-
#[derive(Debug)]
84-
pub struct FinalizeResponseError(InternalFinalizeResponseError);
85-
86-
#[derive(Debug)]
87-
pub(crate) enum InternalFinalizeResponseError {
88-
DirectoryResponse(DirectoryResponseError),
89-
}
90-
91-
impl From<InternalFinalizeResponseError> for FinalizeResponseError {
92-
fn from(value: InternalFinalizeResponseError) -> Self { FinalizeResponseError(value) }
93-
}
94-
95-
impl From<DirectoryResponseError> for FinalizeResponseError {
96-
fn from(err: DirectoryResponseError) -> Self {
97-
FinalizeResponseError(InternalFinalizeResponseError::DirectoryResponse(err))
98-
}
99-
}
100-
101-
impl Display for FinalizeResponseError {
102-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.0) }
103-
}
104-
105-
impl std::error::Error for FinalizeResponseError {
106-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
107-
match &self.0 {
108-
InternalFinalizeResponseError::DirectoryResponse(e) => Some(e),
109-
}
110-
}
111-
}

payjoin/src/send/multiparty/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bitcoin::{FeeRate, Psbt};
22
use error::{
3-
CreateRequestError, FinalizeResponseError, FinalizedError, InternalCreateRequestError,
4-
InternalFinalizedError,
3+
CreateRequestError, FinalizedError, InternalCreateRequestError, InternalFinalizedError,
54
};
65
use serde::{Deserialize, Serialize};
76
use url::Url;
@@ -192,7 +191,7 @@ impl FinalizeContext {
192191
self,
193192
response: &[u8],
194193
ohttp_ctx: ohttp::ClientResponse,
195-
) -> Result<(), FinalizeResponseError> {
194+
) -> Result<(), FinalizedError> {
196195
match process_post_res(response, ohttp_ctx) {
197196
Ok(()) => Ok(()),
198197
Err(e) => Err(e.into()),

0 commit comments

Comments
 (0)