1use iroh::EndpointId;
2
3#[derive(Debug)]
5pub enum AuthenticatorError {
6 AddFailed,
7 AcceptFailed(String),
8 OpenFailed(String),
9 AcceptFailedAndBlock(String, EndpointId),
10 OpenFailedAndBlock(String, EndpointId),
11 EndpointNotSet,
12}
13
14#[derive(Debug)]
15pub enum InFlightError {
16 PromotionNotAllowed(String),
17}
18
19impl std::fmt::Display for AuthenticatorError {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 AuthenticatorError::AddFailed => write!(f, "Failed to add authenticated ID"),
23 AuthenticatorError::AcceptFailed(msg) => write!(f, "Accept failed: {}", msg),
24 AuthenticatorError::OpenFailed(msg) => write!(f, "Open failed: {}", msg),
25 AuthenticatorError::EndpointNotSet => write!(
26 f,
27 "Authenticator endpoint not set: missing authenticator.set_endpoint(endpoint).await"
28 ),
29 AuthenticatorError::AcceptFailedAndBlock(msg, id) => {
30 write!(f, "Accept blocked endpoint ID: {}: {}", msg, id)
31 }
32 AuthenticatorError::OpenFailedAndBlock(msg, id) => {
33 write!(f, "Open blocked endpoint ID: {}: {}", msg, id)
34 }
35 }
36 }
37}
38
39impl std::fmt::Display for InFlightError {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 match self {
42 InFlightError::PromotionNotAllowed(msg) => write!(f, "Promotion not allowed: {}", msg),
43 }
44 }
45}
46
47impl std::error::Error for InFlightError {}
48impl std::error::Error for AuthenticatorError {}