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

payjoin / rust-payjoin / 15642374656

13 Jun 2025 07:22PM UTC coverage: 84.642% (-1.4%) from 86.035%
15642374656

Pull #768

github

web-flow
Merge 605fdfd6b into be0597869
Pull Request #768: Add PartialEq/Eq to errors for easier comparison

22 of 162 new or added lines in 13 files covered. (13.58%)

304 existing lines in 9 files now uncovered.

7137 of 8432 relevant lines covered (84.64%)

550.77 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 sled::Error as SledError;
7

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

10
#[derive(Debug)]
11
pub(crate) enum Error {
12
    Sled(SledError),
13
    #[cfg(feature = "v2")]
14
    Serialize(serde_json::Error),
15
    #[cfg(feature = "v2")]
16
    Deserialize(serde_json::Error),
17
    #[cfg(feature = "v2")]
18
    NotFound(String),
19
}
20

21
impl PartialEq for Error {
NEW
22
    fn eq(&self, other: &Self) -> bool {
×
NEW
23
        match (self, other) {
×
NEW
24
            (Error::Sled(_), Error::Sled(_)) => true,
×
25
            #[cfg(feature = "v2")]
NEW
26
            (Error::Serialize(_), Error::Serialize(_)) => true,
×
27
            #[cfg(feature = "v2")]
NEW
28
            (Error::Deserialize(_), Error::Deserialize(_)) => true,
×
29
            #[cfg(feature = "v2")]
NEW
30
            (Error::NotFound(s1), Error::NotFound(s2)) => s1 == s2,
×
NEW
31
            _ => false,
×
32
        }
NEW
UNCOV
33
    }
×
34
}
35

36
impl Eq for Error {}
37

38
impl fmt::Display for Error {
UNCOV
39
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
40
        match self {
×
41
            Error::Sled(e) => write!(f, "Database operation failed: {e}"),
×
42
            #[cfg(feature = "v2")]
×
43
            Error::Serialize(e) => write!(f, "Serialization failed: {e}"),
×
UNCOV
44
            #[cfg(feature = "v2")]
×
UNCOV
45
            Error::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
×
UNCOV
46
            #[cfg(feature = "v2")]
×
UNCOV
47
            Error::NotFound(key) => write!(f, "Key not found: {key}"),
×
UNCOV
48
        }
×
UNCOV
49
    }
×
50
}
51

52
impl std::error::Error for Error {}
53

54
impl From<SledError> for Error {
UNCOV
55
    fn from(error: SledError) -> Self { Error::Sled(error) }
×
56
}
57

58
impl From<Error> for ImplementationError {
NEW
UNCOV
59
    fn from(error: Error) -> Self { ImplementationError::new(error) }
×
60
}
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