derec_library/primitives/pairing/
error.rs1#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum PairingError {
7 #[error("transport_uri is empty")]
8 EmptyTransportUri,
9
10 #[error("invalid contact message: {0}")]
11 InvalidContactMessage(&'static str),
12
13 #[error("invalid pairing request message: {0}")]
14 InvalidPairRequestMessage(&'static str),
15
16 #[error("invalid pairing response message: {0}")]
17 InvalidPairResponseMessage(&'static str),
18
19 #[error("pairing response indicates a non-OK status (status={status}): {memo}")]
20 NonOkStatus { status: i32, memo: String },
21
22 #[error("pairing protocol violation: {0}")]
23 ProtocolViolation(&'static str),
24
25 #[error("contact binding hash mismatch: published keys do not match the contact commitment")]
26 PrePairHashMismatch,
27
28 #[error(
29 "replica-mode pairing (sender_kind={sender_kind:?}) missing the reserved `derec.replica_id` key"
30 )]
31 MissingReplicaId {
32 sender_kind: derec_proto::SenderKind,
33 },
34
35 #[error(
36 "non-replica pairing (sender_kind={sender_kind:?}) carries the reserved `derec.replica_id` key"
37 )]
38 UnexpectedReplicaId {
39 sender_kind: derec_proto::SenderKind,
40 },
41
42 #[error(
47 "incompatible parameter range on `{field}`: local=[{local_min}, {local_max}], peer=[{peer_min}, {peer_max}]"
48 )]
49 IncompatibleParameterRange {
50 field: &'static str,
51 local_min: i64,
52 local_max: i64,
53 peer_min: i64,
54 peer_max: i64,
55 },
56
57 #[error("internal invariant violated: {0}")]
58 Invariant(&'static str),
59
60 #[error("failed to generate contact message key material")]
61 ContactMessageKeygen {
62 #[source]
63 source: derec_cryptography::pairing::DerecPairingError,
64 },
65
66 #[error("failed to generate pairing request key material")]
67 PairRequestKeygen {
68 #[source]
69 source: derec_cryptography::pairing::DerecPairingError,
70 },
71
72 #[error("failed to finalize pairing (initiator side)")]
73 FinishPairingInitiator {
74 #[source]
75 source: derec_cryptography::pairing::DerecPairingError,
76 },
77
78 #[error("failed to finalize pairing (responder side)")]
79 FinishPairingResponder {
80 #[source]
81 source: derec_cryptography::pairing::DerecPairingError,
82 },
83
84 #[error(transparent)]
85 PairingEncryption(#[from] derec_cryptography::pairing::envelope::DerecEncryptionError),
86}