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

payjoin / rust-payjoin / 16254101487

13 Jul 2025 10:27PM UTC coverage: 85.698% (+0.1%) from 85.566%
16254101487

Pull #873

github

web-flow
Merge 2e0bbfbb3 into 145d1cfc6
Pull Request #873: Migrate payjoin-cli from sled to rusqlite

147 of 166 new or added lines in 3 files covered. (88.55%)

28 existing lines in 3 files now uncovered.

7682 of 8964 relevant lines covered (85.7%)

522.44 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 r2d2::Error as R2d2Error;
6
use rusqlite::Error as RusqliteError;
7

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

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

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

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

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

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

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