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

payjoin / rust-payjoin / 16427048792

21 Jul 2025 08:09PM UTC coverage: 85.706% (-0.09%) from 85.8%
16427048792

push

github

web-flow
Add PartialEq/Eq to errors for easier comparison (#768)

The biggest change here is the change of `payjoin::ImplementationError`
from a type alias to a newtype. This update required adding some
implementations to `ImplementationError` from other errors we use. To
prevent adding a bunch of dependencies to `payjoin`, I also opted for
manually wrapping errors using `.map_err(ImplementationError::new)` in
many places instead of implementing `From<SomeNewDependecyError> for
ImplementationError`. It's not necessarily the cleanest; it exposes some
places for improvements in error handling. However, I assume #403 will
tighten some of this up.

Closes #645

73 of 99 new or added lines in 9 files covered. (73.74%)

2 existing lines in 2 files now uncovered.

7741 of 9032 relevant lines covered (85.71%)

518.67 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
    #[cfg(feature = "v2")]
20
    TryFromSlice(std::array::TryFromSliceError),
21
}
22

23
impl fmt::Display for Error {
24
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
25
        match self {
×
26
            Error::Sled(e) => write!(f, "Database operation failed: {e}"),
×
27
            #[cfg(feature = "v2")]
28
            Error::Serialize(e) => write!(f, "Serialization failed: {e}"),
×
29
            #[cfg(feature = "v2")]
30
            Error::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
×
31
            #[cfg(feature = "v2")]
32
            Error::NotFound(key) => write!(f, "Key not found: {key}"),
×
33
            #[cfg(feature = "v2")]
34
            Error::TryFromSlice(e) => write!(f, "TryFromSlice failed: {e}"),
×
35
        }
36
    }
×
37
}
38

39
impl std::error::Error for Error {}
40

41
impl From<SledError> for Error {
42
    fn from(error: SledError) -> Self { Error::Sled(error) }
×
43
}
44

45
impl From<Error> for ImplementationError {
NEW
46
    fn from(error: Error) -> Self { ImplementationError::new(error) }
×
47
}
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