Skip to content

Commit e8785fb

Browse files
committed
Fix Dart receiver issue bindings
Rename the nested receiver detail UniFFI objects away from\ntrailing Error names so regenerated Dart bindings stay\nself-consistent.\n\nThe Dart generator maps object declarations ending in Error to\nException classes, but the new optional accessors on\nProtocolError were still emitted with the original Rust type\nnames. That left the generated bindings referring to\nnonexistent PayloadError, RequestError, and SessionError\nclasses after regeneration.\n\nKeep the top-level SessionError exception for direct result paths,\nbut expose the nested protocol detail objects as PayloadIssue,\nRequestIssue, and SessionIssue instead. This preserves the\nreceiver error shape while fixing the CI-only Dart build failure\nthat appears after running the binding generator.
1 parent 26c0ed9 commit e8785fb

2 files changed

Lines changed: 38 additions & 17 deletions

File tree

payjoin-ffi/src/receive/error.rs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ pub struct ProtocolError {
242242
kind: ProtocolErrorKind,
243243
message: String,
244244
reply: receive::JsonReply,
245-
payload_error: Option<Arc<PayloadError>>,
246-
request_error: Option<Arc<RequestError>>,
247-
session_error: Option<Arc<SessionError>>,
245+
payload_error: Option<Arc<PayloadIssue>>,
246+
request_error: Option<Arc<RequestIssue>>,
247+
session_error: Option<Arc<SessionIssue>>,
248248
}
249249

250250
impl From<receive::ProtocolError> for ProtocolError {
@@ -288,11 +288,11 @@ impl ProtocolError {
288288

289289
pub fn message(&self) -> String { self.message.clone() }
290290

291-
pub fn payload_error(&self) -> Option<Arc<PayloadError>> { self.payload_error.clone() }
291+
pub fn payload_error(&self) -> Option<Arc<PayloadIssue>> { self.payload_error.clone() }
292292

293-
pub fn request_error(&self) -> Option<Arc<RequestError>> { self.request_error.clone() }
293+
pub fn request_error(&self) -> Option<Arc<RequestIssue>> { self.request_error.clone() }
294294

295-
pub fn session_error(&self) -> Option<Arc<SessionError>> { self.session_error.clone() }
295+
pub fn session_error(&self) -> Option<Arc<SessionIssue>> { self.session_error.clone() }
296296
}
297297

298298
/// The standard format for errors that can be replied as JSON.
@@ -340,16 +340,37 @@ impl SessionError {
340340
pub fn message(&self) -> String { self.message.clone() }
341341
}
342342

343-
/// Receiver original payload validation error exposed over FFI.
343+
/// Receiver protocol session issue exposed over FFI.
344344
#[derive(Debug, thiserror::Error, uniffi::Object)]
345345
#[error("{message}")]
346-
pub struct PayloadError {
346+
pub struct SessionIssue {
347+
kind: SessionErrorKind,
348+
message: String,
349+
}
350+
351+
impl From<receive::v2::SessionError> for SessionIssue {
352+
fn from(value: receive::v2::SessionError) -> Self {
353+
Self { kind: value.kind().into(), message: value.to_string() }
354+
}
355+
}
356+
357+
#[uniffi::export]
358+
impl SessionIssue {
359+
pub fn kind(&self) -> SessionErrorKind { self.kind }
360+
361+
pub fn message(&self) -> String { self.message.clone() }
362+
}
363+
364+
/// Receiver original payload issue exposed over FFI.
365+
#[derive(Debug, thiserror::Error, uniffi::Object)]
366+
#[error("{message}")]
367+
pub struct PayloadIssue {
347368
kind: PayloadErrorKind,
348369
message: String,
349370
supported_versions: Option<Vec<u64>>,
350371
}
351372

352-
impl From<receive::PayloadError> for PayloadError {
373+
impl From<receive::PayloadError> for PayloadIssue {
353374
fn from(value: receive::PayloadError) -> Self {
354375
Self {
355376
kind: value.kind().into(),
@@ -360,18 +381,18 @@ impl From<receive::PayloadError> for PayloadError {
360381
}
361382

362383
#[uniffi::export]
363-
impl PayloadError {
384+
impl PayloadIssue {
364385
pub fn kind(&self) -> PayloadErrorKind { self.kind }
365386

366387
pub fn message(&self) -> String { self.message.clone() }
367388

368389
pub fn supported_versions(&self) -> Option<Vec<u64>> { self.supported_versions.clone() }
369390
}
370391

371-
/// Receiver v1 request validation error exposed over FFI.
392+
/// Receiver v1 request issue exposed over FFI.
372393
#[derive(Debug, thiserror::Error, uniffi::Object)]
373394
#[error("{message}")]
374-
pub struct RequestError {
395+
pub struct RequestIssue {
375396
kind: RequestErrorKind,
376397
message: String,
377398
header_name: Option<String>,
@@ -380,7 +401,7 @@ pub struct RequestError {
380401
actual_content_length: Option<u64>,
381402
}
382403

383-
impl From<receive::v1::RequestError> for RequestError {
404+
impl From<receive::v1::RequestError> for RequestIssue {
384405
fn from(value: receive::v1::RequestError) -> Self {
385406
Self {
386407
kind: value.kind().into(),
@@ -394,7 +415,7 @@ impl From<receive::v1::RequestError> for RequestError {
394415
}
395416

396417
#[uniffi::export]
397-
impl RequestError {
418+
impl RequestIssue {
398419
pub fn kind(&self) -> RequestErrorKind { self.kind }
399420

400421
pub fn message(&self) -> String { self.message.clone() }

payjoin-ffi/src/receive/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::sync::{Arc, RwLock};
33

44
pub use error::{
55
AddressParseError, InputContributionError, InputPairError, JsonReply, OutputSubstitutionError,
6-
PayloadError, PayloadErrorKind, ProtocolError, ProtocolErrorKind, PsbtInputError,
7-
ReceiverBuilderError, ReceiverError, RequestError, RequestErrorKind, SelectionError,
8-
SessionError, SessionErrorKind,
6+
PayloadErrorKind, PayloadIssue, ProtocolError, ProtocolErrorKind, PsbtInputError,
7+
ReceiverBuilderError, ReceiverError, RequestErrorKind, RequestIssue, SelectionError,
8+
SessionError, SessionErrorKind, SessionIssue,
99
};
1010
use payjoin::bitcoin::consensus::Decodable;
1111
use payjoin::bitcoin::psbt::Psbt;

0 commit comments

Comments
 (0)