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

payjoin / rust-payjoin / 12918406633

22 Jan 2025 10:39PM UTC coverage: 65.801% (-6.3%) from 72.12%
12918406633

Pull #502

github

web-flow
Merge 2152c4b39 into 7d8116e03
Pull Request #502: Introduce `directory` feature module

69 of 129 new or added lines in 11 files covered. (53.49%)

270 existing lines in 14 files now uncovered.

3219 of 4892 relevant lines covered (65.8%)

933.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/payjoin/src/receive/v2/error.rs
1
use core::fmt;
2
use std::error;
3

4
use super::Error;
5
use crate::hpke::HpkeError;
6
use crate::ohttp::OhttpEncapsulationError;
7

8
/// Error that may occur during a v2 session typestate change
9
///
10
/// This is currently opaque type because we aren't sure which variants will stay.
11
/// You can only display it.
12
#[derive(Debug)]
13
pub struct SessionError(InternalSessionError);
14

15
impl From<InternalSessionError> for SessionError {
UNCOV
16
    fn from(value: InternalSessionError) -> Self { SessionError(value) }
×
17
}
18

19
impl From<InternalSessionError> for super::Error {
UNCOV
20
    fn from(e: InternalSessionError) -> Self { super::Error::Validation(e.into()) }
×
21
}
22

23
#[derive(Debug)]
24
pub(crate) enum InternalSessionError {
25
    /// The session has expired
26
    Expired(std::time::SystemTime),
27
    /// OHTTP Encapsulation failed
28
    OhttpEncapsulation(OhttpEncapsulationError),
29
    /// Hybrid Public Key Encryption failed
30
    Hpke(HpkeError),
31
    /// Unexpected response size
32
    UnexpectedResponseSize(usize),
33
    /// Unexpected status code
34
    UnexpectedStatusCode(http::StatusCode),
35
}
36

37
impl From<std::time::SystemTime> for Error {
38
    fn from(e: std::time::SystemTime) -> Self { InternalSessionError::Expired(e).into() }
×
39
}
40

41
impl From<OhttpEncapsulationError> for Error {
42
    fn from(e: OhttpEncapsulationError) -> Self {
×
43
        InternalSessionError::OhttpEncapsulation(e).into()
×
44
    }
×
45
}
46

47
impl From<HpkeError> for Error {
48
    fn from(e: HpkeError) -> Self { InternalSessionError::Hpke(e).into() }
×
49
}
50

51
impl fmt::Display for SessionError {
UNCOV
52
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
×
UNCOV
53
        match &self.0 {
×
UNCOV
54
            InternalSessionError::Expired(expiry) => write!(f, "Session expired at {:?}", expiry),
×
55
            InternalSessionError::OhttpEncapsulation(e) =>
×
56
                write!(f, "OHTTP Encapsulation Error: {}", e),
×
57
            InternalSessionError::Hpke(e) => write!(f, "Hpke decryption failed: {}", e),
×
58
            InternalSessionError::UnexpectedResponseSize(size) => write!(
×
59
                f,
×
60
                "Unexpected response size {}, expected {} bytes",
×
61
                size,
×
NEW
62
                crate::directory::ENCAPSULATED_MESSAGE_BYTES
×
63
            ),
×
64
            InternalSessionError::UnexpectedStatusCode(status) =>
×
65
                write!(f, "Unexpected status code: {}", status),
×
66
        }
UNCOV
67
    }
×
68
}
69

70
impl error::Error for SessionError {
71
    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
×
72
        match &self.0 {
×
73
            InternalSessionError::Expired(_) => None,
×
74
            InternalSessionError::OhttpEncapsulation(e) => Some(e),
×
75
            InternalSessionError::Hpke(e) => Some(e),
×
76
            InternalSessionError::UnexpectedResponseSize(_) => None,
×
77
            InternalSessionError::UnexpectedStatusCode(_) => None,
×
78
        }
79
    }
×
80
}
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