sos_net/pairing/
error.rs

1//! Error type for the pairing module.
2use sos_core::AccountId;
3use thiserror::Error;
4
5/// Errors generated by the pairing library.
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Error generated trying to parse a pairing URL.
9    #[error("invalid pairing url")]
10    InvalidShareUrl,
11
12    /// Error generated if a packet has a to public key that does not
13    /// match the recipient key pair.
14    #[error("packet is not for me (wrong public key)")]
15    NotForMe,
16
17    /// Error generated failing to sync devices patch.
18    #[error("failed to sync devices: {0}")]
19    DevicePatchSync(Box<crate::Error>),
20
21    /// Error generated trying to access device enrollment
22    /// before pairing protocol completion.
23    #[error("enrollment is not available")]
24    NoEnrollment,
25
26    /// Error generated trying to finish device enrollment
27    /// before fetching the account data.
28    #[error("account must be fetched before authenticating a new device")]
29    AccountNotFetched,
30
31    /// Error generated attempting to enroll a new device and
32    /// the account already exists on the device.
33    #[error("cannot enroll, account '{0}' already exists on this device")]
34    EnrollAccountExists(AccountId),
35
36    /// Error generated when failing to sync after completing
37    /// device enrollment.
38    #[error("could not sync after device enrollment authentication: '{0}'")]
39    EnrollSync(Box<crate::Error>),
40
41    /// Error generated when the protocol is in the wrong state
42    /// or a packet payload is not of the expected type.
43    #[error("pairing protocol bad state or invalid packet payload")]
44    BadState,
45
46    /// Error generated by the client library.
47    #[error(transparent)]
48    Client(#[from] crate::Error),
49
50    /// Error generated by the core library.
51    #[error(transparent)]
52    Core(#[from] sos_core::Error),
53
54    /// Error generated by the backend library.
55    #[error(transparent)]
56    Backend(#[from] sos_backend::Error),
57
58    /// Error generated by the login library.
59    #[error(transparent)]
60    Login(#[from] sos_login::Error),
61
62    /// Error generated by the signer library.
63    #[error(transparent)]
64    Signer(#[from] sos_signer::Error),
65
66    /// Error generated by the vault library.
67    #[error(transparent)]
68    Vault(#[from] sos_vault::Error),
69
70    /// Error generated by the database library.
71    #[error(transparent)]
72    Database(#[from] sos_database::Error),
73
74    /// Error generated by the backend storage.
75    #[error(transparent)]
76    BackendStorage(#[from] sos_backend::StorageError),
77
78    /// Error generated by the account library.
79    #[error(transparent)]
80    Account(#[from] sos_account::Error),
81
82    /// Error generated by the storage library.
83    #[error(transparent)]
84    Storage(#[from] sos_client_storage::Error),
85
86    /// Error generated by the io module.
87    #[error(transparent)]
88    Io(#[from] std::io::Error),
89
90    /// Error generated by the JSON library.
91    #[error(transparent)]
92    Json(#[from] serde_json::Error),
93
94    /// Error generated when parsing from hex.
95    #[error(transparent)]
96    Hex(#[from] hex::FromHexError),
97
98    /// Error generated attempting to convert from a slice.
99    #[error(transparent)]
100    TryFromSlice(#[from] std::array::TryFromSliceError),
101
102    /// Error generated attempting to parse a URL.
103    #[error(transparent)]
104    UrlParse(#[from] url::ParseError),
105
106    /// Error generated by the snow noise protocol library.
107    #[error(transparent)]
108    Snow(#[from] snow::Error),
109
110    /// Error generated by the websocket client.
111    #[error(transparent)]
112    WebSocket(#[from] sos_protocol::tokio_tungstenite::tungstenite::Error),
113
114    /// Error generated by the protocol module.
115    #[error(transparent)]
116    Protocol(#[from] sos_protocol::Error),
117
118    /// Error generated by the protobuf library when encoding.
119    #[error(transparent)]
120    ProtoBufEncode(#[from] prost::EncodeError),
121
122    /// Error generated by the protobuf library when decoding.
123    #[error(transparent)]
124    ProtoBufDecode(#[from] prost::DecodeError),
125}