ic_query/icrc/model/
error.rs1#[cfg(feature = "cli")]
8use crate::cli::common::CurrentUnixSecsError;
9#[cfg(feature = "host")]
10use crate::runtime::RuntimeError;
11use std::io;
12use thiserror::Error as ThisError;
13
14#[derive(Debug, ThisError)]
21pub enum IcrcError {
22 #[error("{0}")]
23 Usage(String),
24
25 #[cfg(feature = "cli")]
26 #[error(transparent)]
27 Clock(#[from] CurrentUnixSecsError),
28
29 #[cfg(feature = "host")]
30 #[error("failed to create Tokio runtime for ICRC query: {0}")]
31 Runtime(#[from] RuntimeError),
32
33 #[error("failed to build IC agent for endpoint {endpoint}: {reason}")]
34 AgentBuild { endpoint: String, reason: String },
35
36 #[error("invalid {field}: {reason}")]
37 InvalidPrincipal { field: &'static str, reason: String },
38
39 #[error("invalid subaccount hex: {reason}")]
40 InvalidSubaccountHex { reason: String },
41
42 #[error("invalid subaccount length: expected 32 bytes, got {bytes}")]
43 InvalidSubaccountLength { bytes: usize },
44
45 #[error("failed to encode Candid request for {message}: {reason}")]
46 CandidEncode {
47 message: &'static str,
48 reason: String,
49 },
50
51 #[error("ICRC ledger method {method} failed: {reason}")]
52 AgentCall {
53 method: &'static str,
54 reason: String,
55 },
56
57 #[error("failed to decode Candid response {message}: {reason}")]
58 CandidDecode {
59 message: &'static str,
60 reason: String,
61 },
62
63 #[error(transparent)]
64 Io(#[from] io::Error),
65
66 #[error(transparent)]
67 Json(#[from] serde_json::Error),
68}