tai_core/error.rs
1//! Crate-wide error type.
2
3use thiserror::Error;
4
5/// The single error type returned by every fallible `tai-core` function.
6#[derive(Debug, Error)]
7pub enum TaiError {
8 /// A configuration file could not be loaded or was malformed.
9 #[error("config error: {0}")]
10 Config(String),
11
12 /// A signer operation failed.
13 #[error("signer error: {0}")]
14 Signer(String),
15
16 /// A Sui RPC call failed.
17 #[error("rpc error: {0}")]
18 Rpc(String),
19
20 /// The RPC server returned an unexpected shape.
21 #[error("rpc response shape: {0}")]
22 RpcShape(String),
23
24 /// An address or object ID could not be parsed.
25 #[error("invalid address/id: {0}")]
26 InvalidAddress(String),
27
28 /// A Move object could not be decoded from its on-chain representation.
29 #[error("decode error: {0}")]
30 Decode(String),
31
32 /// A transaction was constructed but failed to execute.
33 #[error("transaction failed: {0}")]
34 TxFailed(String),
35
36 /// I/O failure (filesystem etc).
37 #[error("io: {0}")]
38 Io(#[from] std::io::Error),
39
40 /// JSON serialization failed.
41 #[error("serde_json: {0}")]
42 SerdeJson(#[from] serde_json::Error),
43
44 /// HTTP transport failed.
45 #[error("http: {0}")]
46 Http(#[from] reqwest::Error),
47
48 /// BCS serialization failed.
49 #[error("bcs: {0}")]
50 Bcs(#[from] bcs::Error),
51
52 /// Hex decode failed.
53 #[error("hex: {0}")]
54 Hex(#[from] hex::FromHexError),
55
56 /// Catch-all wrapping `anyhow::Error` for things that don't merit a
57 /// dedicated variant.
58 #[error("{0}")]
59 Other(#[from] anyhow::Error),
60}