Skip to main content

cosm_orc/orchestrator/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum StoreError {
5    #[error("error reading wasm_dir")]
6    WasmDirRead { source: std::io::Error },
7
8    #[error("error reading wasm file")]
9    WasmFileRead { source: std::io::Error },
10
11    #[error("wasm contract file name was not valid utf8 or malformed")]
12    InvalidWasmFileName,
13
14    #[error(transparent)]
15    CosmwasmError(#[from] CosmwasmError),
16
17    #[error(transparent)]
18    IOError(#[from] std::io::Error),
19}
20
21impl StoreError {
22    pub fn wasmdir(e: std::io::Error) -> StoreError {
23        StoreError::WasmDirRead { source: e }
24    }
25
26    pub fn wasmfile(e: std::io::Error) -> StoreError {
27        StoreError::WasmFileRead { source: e }
28    }
29}
30
31#[derive(Error, Debug)]
32pub enum ProcessError {
33    #[error("serde json serialization error")]
34    JsonSerialize { source: serde_json::Error },
35
36    #[error(transparent)]
37    ContractMapError(#[from] ContractMapError),
38
39    #[error(transparent)]
40    CosmwasmError(#[from] CosmwasmError),
41
42    #[error(transparent)]
43    IOError(#[from] std::io::Error),
44}
45
46impl ProcessError {
47    pub fn json(e: serde_json::Error) -> ProcessError {
48        ProcessError::JsonSerialize { source: e }
49    }
50}
51
52#[derive(Error, Debug, PartialEq, Eq)]
53pub enum ContractMapError {
54    #[error("smart contract not stored on chain: {name:?}")]
55    NotStored { name: String },
56
57    #[error("smart contract with addr not initialized on chain: {name:?}")]
58    NotDeployed { name: String },
59}
60
61#[derive(Error, Debug)]
62pub enum OptimizeError {
63    #[error("error running optimizoor")]
64    Optimize {
65        source: Box<dyn std::error::Error + Send + Sync>,
66    },
67}
68
69#[derive(Error, Debug)]
70pub enum PollBlockError {
71    #[error(transparent)]
72    Timeout(#[from] Elapsed),
73
74    #[error(transparent)]
75    TendermintError(#[from] TendermintError),
76}
77
78pub use cosm_tome::chain::error::ChainError;
79pub use cosm_tome::modules::auth::error::AccountError;
80pub use cosm_tome::modules::cosmwasm::error::CosmwasmError;
81pub use cosm_tome::modules::tendermint::error::TendermintError;
82pub use cosm_tome::modules::tx::error::TxError;
83pub use tokio::time::error::Elapsed;