• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

payjoin / rust-payjoin / 17911078509

22 Sep 2025 09:35AM UTC coverage: 84.684% (-0.06%) from 84.743%
17911078509

Pull #1029

github

web-flow
Merge 999c429b2 into 7dbce99da
Pull Request #1029: FFI: tighten error conversions

0 of 7 new or added lines in 1 file covered. (0.0%)

14 existing lines in 1 file now uncovered.

8559 of 10107 relevant lines covered (84.68%)

484.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/payjoin/src/core/error.rs
1
use std::fmt::Debug;
2
use std::{error, fmt};
3

4
#[derive(Debug)]
5
pub struct ImplementationError(Box<dyn error::Error + Send + Sync>);
6

7
impl ImplementationError {
8
    pub fn new(e: impl error::Error + Send + Sync + 'static) -> Self {
6✔
9
        ImplementationError(Box::new(e))
6✔
10
    }
6✔
11
}
12

13
impl fmt::Display for ImplementationError {
14
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { std::fmt::Display::fmt(&self.0, f) }
17✔
15
}
16

17
impl error::Error for ImplementationError {
18
    fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(self.0.as_ref()) }
×
19
}
20

21
impl PartialEq for ImplementationError {
22
    fn eq(&self, _: &Self) -> bool { false }
×
23
}
24

25
impl Eq for ImplementationError {}
26

27
impl From<Box<dyn error::Error + Send + Sync>> for ImplementationError {
28
    fn from(e: Box<dyn error::Error + Send + Sync>) -> Self { ImplementationError(e) }
24✔
29
}
30

31
impl From<&str> for ImplementationError {
32
    fn from(e: &str) -> Self {
24✔
33
        let error = Box::<dyn error::Error + Send + Sync>::from(e);
24✔
34
        ImplementationError::from(error)
24✔
35
    }
24✔
36
}
37
impl From<std::io::Error> for ImplementationError {
NEW
UNCOV
38
    fn from(e: std::io::Error) -> Self { ImplementationError::new(e) }
×
39
}
40
impl From<std::io::ErrorKind> for ImplementationError {
NEW
UNCOV
41
    fn from(kind: std::io::ErrorKind) -> Self {
×
NEW
UNCOV
42
        ImplementationError::new(std::io::Error::from(kind))
×
NEW
UNCOV
43
    }
×
44
}
45
// Allow mapping poisoned lock errors generically without carrying the guard
46
impl<T> From<std::sync::PoisonError<T>> for ImplementationError {
NEW
UNCOV
47
    fn from(_: std::sync::PoisonError<T>) -> Self {
×
48
        // Map to a unit PoisonError which is Error + Send + Sync + 'static
NEW
49
        ImplementationError::new(std::sync::PoisonError::new(()))
×
NEW
50
    }
×
51
}
52
/// Errors that can occur when replaying a session event log
53
#[cfg(feature = "v2")]
54
#[derive(Debug)]
55
pub struct ReplayError<SessionState, SessionEvent>(InternalReplayError<SessionState, SessionEvent>);
56

57
#[cfg(feature = "v2")]
58
impl<SessionState: Debug, SessionEvent: Debug> std::fmt::Display
59
    for ReplayError<SessionState, SessionEvent>
60
{
UNCOV
61
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
×
62
        use InternalReplayError::*;
UNCOV
63
        match &self.0 {
×
UNCOV
64
            NoEvents => write!(f, "No events found in session"),
×
UNCOV
65
            InvalidEvent(event, session) => match session {
×
UNCOV
66
                Some(session) => write!(f, "Invalid event ({event:?}) for session ({session:?})",),
×
UNCOV
67
                None => write!(f, "Invalid first event ({event:?}) for session",),
×
68
            },
UNCOV
69
            PersistenceFailure(e) => write!(f, "Persistence failure: {e}"),
×
70
        }
UNCOV
71
    }
×
72
}
73
#[cfg(feature = "v2")]
74
impl<SessionState: Debug, SessionEvent: Debug> std::error::Error
75
    for ReplayError<SessionState, SessionEvent>
76
{
77
}
78

79
#[cfg(feature = "v2")]
80
impl<SessionState: Debug, SessionEvent: Debug> From<InternalReplayError<SessionState, SessionEvent>>
81
    for ReplayError<SessionState, SessionEvent>
82
{
UNCOV
83
    fn from(e: InternalReplayError<SessionState, SessionEvent>) -> Self { ReplayError(e) }
×
84
}
85

86
#[cfg(feature = "v2")]
87
#[derive(Debug)]
88
pub(crate) enum InternalReplayError<SessionState, SessionEvent> {
89
    /// No events in the event log
90
    NoEvents,
91
    /// Invalid initial event
92
    InvalidEvent(Box<SessionEvent>, Option<Box<SessionState>>),
93
    /// Application storage error
94
    PersistenceFailure(ImplementationError),
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc