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

payjoin / rust-payjoin / 17495099954

05 Sep 2025 01:49PM UTC coverage: 86.021% (+0.08%) from 85.94%
17495099954

Pull #1014

github

web-flow
Merge fedd47a32 into e8829f334
Pull Request #1014: Remove uninitialized session state

42 of 53 new or added lines in 5 files covered. (79.25%)

47 existing lines in 3 files now uncovered.

8215 of 9550 relevant lines covered (86.02%)

489.53 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) }
23✔
29
}
30

31
impl From<&str> for ImplementationError {
32
    fn from(e: &str) -> Self {
23✔
33
        let error = Box::<dyn error::Error + Send + Sync>::from(e);
23✔
34
        ImplementationError::from(error)
23✔
35
    }
23✔
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✔
NEW
49
            NoEvents => write!(f, "No events found in session"),
×
NEW
50
            InvalidEvent(event, session) => match session {
×
NEW
51
                Some(session) => write!(f, "Invalid event ({event:?}) for session ({session:?})",),
×
NEW
52
                None => write!(f, "Invalid first event ({event:?}) for session",),
×
53
            },
NEW
54
            PersistenceFailure(e) => write!(f, "Persistence failure: {e}"),
×
55
            SessionExpired(expiry) => write!(f, "Session expired at {expiry:?}"),
2✔
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
    /// Session expired
76
    SessionExpired(std::time::SystemTime),
77
    /// No events in the event log
78
    NoEvents,
79
    /// Invalid initial event
80
    InvalidEvent(Box<SessionEvent>, Option<Box<SessionState>>),
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