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

payjoin / rust-payjoin / 17960898192

23 Sep 2025 10:40PM UTC coverage: 84.398% (-0.1%) from 84.536%
17960898192

Pull #1060

github

web-flow
Merge e0d168ef2 into e8bb1a7c3
Pull Request #1060: Handle fatal errors in receiver state machine

130 of 186 new or added lines in 6 files covered. (69.89%)

6 existing lines in 4 files now uncovered.

8666 of 10268 relevant lines covered (84.4%)

476.64 hits per line

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

66.67
/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) }
14✔
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) }
26✔
29
}
30

31
impl From<&str> for ImplementationError {
32
    fn from(e: &str) -> Self {
26✔
33
        let error = Box::<dyn error::Error + Send + Sync>::from(e);
26✔
34
        ImplementationError::from(error)
26✔
35
    }
26✔
36
}
37
/// Errors that can occur when replaying a session event log
38
#[cfg(feature = "v2")]
39
#[derive(Debug)]
40
pub struct ReplayError<SessionState, SessionEvent>(InternalReplayError<SessionState, SessionEvent>);
41

42
#[cfg(feature = "v2")]
43
impl<SessionState: Debug, SessionEvent: Debug> std::fmt::Display
44
    for ReplayError<SessionState, SessionEvent>
45
{
46
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2✔
47
        use InternalReplayError::*;
48
        match &self.0 {
2✔
49
            NoEvents => write!(f, "No events found in session"),
×
50
            InvalidEvent(event, session) => match session {
×
51
                Some(session) => write!(f, "Invalid event ({event:?}) for session ({session:?})",),
×
52
                None => write!(f, "Invalid first event ({event:?}) for session",),
×
53
            },
54
            Expired(time) => write!(f, "Session expired at {time:?}"),
2✔
UNCOV
55
            PersistenceFailure(e) => write!(f, "Persistence failure: {e}"),
×
56
        }
57
    }
2✔
58
}
59
#[cfg(feature = "v2")]
60
impl<SessionState: Debug, SessionEvent: Debug> std::error::Error
61
    for ReplayError<SessionState, SessionEvent>
62
{
63
}
64

65
#[cfg(feature = "v2")]
66
impl<SessionState: Debug, SessionEvent: Debug> From<InternalReplayError<SessionState, SessionEvent>>
67
    for ReplayError<SessionState, SessionEvent>
68
{
69
    fn from(e: InternalReplayError<SessionState, SessionEvent>) -> Self { ReplayError(e) }
2✔
70
}
71

72
#[cfg(feature = "v2")]
73
#[derive(Debug)]
74
pub(crate) enum InternalReplayError<SessionState, SessionEvent> {
75
    /// No events in the event log
76
    NoEvents,
77
    /// Invalid initial event
78
    InvalidEvent(Box<SessionEvent>, Option<Box<SessionState>>),
79
    /// Session is expired
80
    Expired(crate::time::Time),
81
    /// Application storage error
82
    PersistenceFailure(ImplementationError),
83
}
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