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

payjoin / rust-payjoin / 17958126512

23 Sep 2025 08:23PM UTC coverage: 84.525% (-0.01%) from 84.536%
17958126512

Pull #1107

github

web-flow
Merge 0b295e82a into e8bb1a7c3
Pull Request #1107: Simply return replay error on expiration

23 of 23 new or added lines in 3 files covered. (100.0%)

3 existing lines in 3 files now uncovered.

8581 of 10152 relevant lines covered (84.53%)

482.07 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) }
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
/// 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 {
4✔
47
        use InternalReplayError::*;
48
        match &self.0 {
4✔
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:?}"),
4✔
UNCOV
55
            PersistenceFailure(e) => write!(f, "Persistence failure: {e}"),
×
56
        }
57
    }
4✔
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) }
4✔
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