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

payjoin / rust-payjoin / 16456252557

22 Jul 2025 09:47PM UTC coverage: 85.622% (-0.08%) from 85.706%
16456252557

Pull #873

github

web-flow
Merge 389ab86f3 into e4badaa21
Pull Request #873: Migrate payjoin-cli from sled to rusqlite

155 of 179 new or added lines in 4 files covered. (86.59%)

1 existing line in 1 file now uncovered.

7801 of 9111 relevant lines covered (85.62%)

514.09 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
#[cfg(feature = "v2")]
4
use bitcoincore_rpc::jsonrpc::serde_json;
5
use payjoin::ImplementationError;
6
use r2d2::Error as R2d2Error;
7
use rusqlite::Error as RusqliteError;
8

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

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

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

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

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

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

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

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