1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::RequestIdError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum AgentError {
#[error(r#"Invalid Replica URL: "{0}""#)]
InvalidReplicaUrl(String),
#[error("The request timed out.")]
TimeoutWaitingForResponse(),
#[error("Identity had a signing error: {0}")]
SigningError(String),
#[error("Invalid CBOR data, could not deserialize: {0}")]
InvalidCborData(#[from] serde_cbor::Error),
#[error("Cannot calculate a RequestID: {0}")]
CannotCalculateRequestId(#[from] RequestIdError),
#[error("Could not reach the server")]
ReqwestError(#[from] reqwest::Error),
#[error("Candid returned an error: {0}")]
CandidError(Box<dyn Send + Sync + std::error::Error>),
#[error(r#"Cannot parse url: "{0}""#)]
UrlParseError(#[from] url::ParseError),
#[error("Cannot parse Principal: {0}")]
PrincipalError(#[from] crate::export::PrincipalError),
#[error(r#"The Replica returned an error: code {reject_code}, message: "{reject_message}""#)]
ReplicaError {
reject_code: u64,
reject_message: String,
},
#[error(r#"The replica returned an HTTP Error: status code {status}"#)]
HttpError {
status: u16,
content_type: Option<String>,
content: Vec<u8>,
},
#[error("HTTP Authentication cannot be used in a non-secure URL (either HTTPS or localhost)")]
CannotUseAuthenticationOnNonSecureUrl(),
#[error("Password Manager returned an error: {0}")]
AuthenticationError(String),
#[error("Status endpoint returned an invalid status.")]
InvalidReplicaStatus,
#[error("Call was marked as done but we never saw the reply. Request ID: {0}")]
RequestStatusDoneNoReply(String),
#[error("A tool returned a string message error: {0}")]
MessageError(String),
#[error("A tool returned a custom error: {0}")]
CustomError(#[from] Box<dyn Send + Sync + std::error::Error>),
}
impl PartialEq for AgentError {
fn eq(&self, other: &Self) -> bool {
format!("{:?}", self) == format!("{:?}", other)
}
}