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

payjoin / rust-payjoin / 18847870589

27 Oct 2025 04:12PM UTC coverage: 83.557% (-0.02%) from 83.578%
18847870589

Pull #1158

github

web-flow
Merge 622a6c6ec into 2009ac0d7
Pull Request #1158: Add completed_event_id FK to prevent session replay

33 of 42 new or added lines in 3 files covered. (78.57%)

8 existing lines in 1 file now uncovered.

9010 of 10783 relevant lines covered (83.56%)

459.32 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
}
18

19
impl fmt::Display for Error {
20
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
UNCOV
21
        match self {
×
UNCOV
22
            Error::Rusqlite(e) => write!(f, "Database operation failed: {e}"),
×
UNCOV
23
            Error::R2d2(e) => write!(f, "Connection pool error: {e}"),
×
24
            #[cfg(feature = "v2")]
25
            Error::Serialize(e) => write!(f, "Serialization failed: {e}"),
×
26
            #[cfg(feature = "v2")]
27
            Error::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
×
28
        }
29
    }
×
30
}
31

32
impl std::error::Error for Error {
33
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
×
34
        match self {
×
35
            Error::Rusqlite(e) => Some(e),
×
36
            Error::R2d2(e) => Some(e),
×
37
            #[cfg(feature = "v2")]
UNCOV
38
            Error::Serialize(e) => Some(e),
×
39
            #[cfg(feature = "v2")]
UNCOV
40
            Error::Deserialize(e) => Some(e),
×
41
        }
42
    }
×
43
}
44

45
impl From<RusqliteError> for Error {
46
    fn from(error: RusqliteError) -> Self { Error::Rusqlite(error) }
×
47
}
48

49
impl From<R2d2Error> for Error {
50
    fn from(error: R2d2Error) -> Self { Error::R2d2(error) }
×
51
}
52

53
#[cfg(feature = "v2")]
54
impl From<serde_json::Error> for Error {
UNCOV
55
    fn from(error: serde_json::Error) -> Self {
×
56
        match error.classify() {
×
UNCOV
57
            serde_json::error::Category::Io => Error::Serialize(error), // I/O errors during writing/serialization
×
58
            serde_json::error::Category::Syntax
59
            | serde_json::error::Category::Data
60
            | serde_json::error::Category::Eof => Error::Deserialize(error), // All parsing/reading errors
×
61
        }
UNCOV
62
    }
×
63
}
64

65
impl From<Error> for ImplementationError {
66
    fn from(error: Error) -> Self { ImplementationError::new(error) }
×
67
}
68

69
impl From<String> for Error {
NEW
70
    fn from(msg: String) -> Self { Error::Rusqlite(rusqlite::Error::InvalidParameterName(msg)) }
×
71
}
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