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

payjoin / rust-payjoin / 19249965305

10 Nov 2025 11:52PM UTC coverage: 83.511% (-0.07%) from 83.578%
19249965305

Pull #1158

github

web-flow
Merge 735d4f5c5 into 7d9e7f556
Pull Request #1158: Add completed_event_id FK to prevent session replay

43 of 60 new or added lines in 3 files covered. (71.67%)

27 existing lines in 1 file now uncovered.

9020 of 10801 relevant lines covered (83.51%)

458.62 hits per line

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

0.0
/payjoin-cli/src/db/error.rs
1
use std::fmt;
2

3
use payjoin::ImplementationError;
4
use r2d2::Error as R2d2Error;
5
use rusqlite::Error as RusqliteError;
6

7
pub(crate) type Result<T> = std::result::Result<T, Error>;
8

9
#[derive(Debug)]
10
pub(crate) enum Error {
11
    Rusqlite(RusqliteError),
12
    R2d2(R2d2Error),
13
    #[cfg(feature = "v2")]
14
    Serialize(serde_json::Error),
15
    #[cfg(feature = "v2")]
16
    Deserialize(serde_json::Error),
17
    #[cfg(feature = "v2")]
18
    MissingCompletedEventId {
19
        session_id: i64,
20
    },
21
}
22

23
impl fmt::Display for Error {
24
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
25
        match self {
×
26
            Error::Rusqlite(e) => write!(f, "Database operation failed: {e}"),
×
27
            Error::R2d2(e) => write!(f, "Connection pool error: {e}"),
×
28
            #[cfg(feature = "v2")]
29
            Error::Serialize(e) => write!(f, "Serialization failed: {e}"),
×
30
            #[cfg(feature = "v2")]
31
            Error::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
×
32
            #[cfg(feature = "v2")]
NEW
33
            Error::MissingCompletedEventId { session_id } => {
×
NEW
34
                write!(f, "completed_event_id for Session {} is none", session_id)
×
35
            }
36
        }
37
    }
×
38
}
39

40
impl std::error::Error for Error {
41
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
×
42
        match self {
×
43
            Error::Rusqlite(e) => Some(e),
×
44
            Error::R2d2(e) => Some(e),
×
45
            #[cfg(feature = "v2")]
46
            Error::Serialize(e) => Some(e),
×
47
            #[cfg(feature = "v2")]
48
            Error::Deserialize(e) => Some(e),
×
49
            #[cfg(feature = "v2")]
NEW
50
            Error::MissingCompletedEventId { .. } => None,
×
51
        }
52
    }
×
53
}
54

55
impl From<RusqliteError> for Error {
56
    fn from(error: RusqliteError) -> Self { Error::Rusqlite(error) }
×
57
}
58

59
impl From<R2d2Error> for Error {
60
    fn from(error: R2d2Error) -> Self { Error::R2d2(error) }
×
61
}
62

63
#[cfg(feature = "v2")]
64
impl From<serde_json::Error> for Error {
65
    fn from(error: serde_json::Error) -> Self {
×
66
        match error.classify() {
×
67
            serde_json::error::Category::Io => Error::Serialize(error), // I/O errors during writing/serialization
×
68
            serde_json::error::Category::Syntax
69
            | serde_json::error::Category::Data
70
            | serde_json::error::Category::Eof => Error::Deserialize(error), // All parsing/reading errors
×
71
        }
72
    }
×
73
}
74

75
impl From<Error> for ImplementationError {
76
    fn from(error: Error) -> Self { ImplementationError::new(error) }
×
77
}
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

© 2025 Coveralls, Inc