eosio_client_api/
errors.rs

1use crate::api_types::ErrorInt;
2
3use error_chain::error_chain;
4
5impl From<Box<dyn std::error::Error>> for Error {
6    fn from(e: Box<dyn std::error::Error>) -> Self {
7        Self::from(format!("{:?}", e))
8    }
9}
10
11impl From<Box<dyn std::error::Error + Sync + Send>> for Error {
12    fn from(e: Box<dyn std::error::Error + Sync + Send>) -> Self {
13        Self::from(format!("{:?}", e))
14    }
15}
16
17#[cfg(test)]
18impl PartialEq for Error {
19    fn eq(&self, _other: &Self) -> bool {
20        // This might be Ok since we try to compare Result in tests
21        false
22    }
23}
24
25error_chain! {
26    foreign_links {
27        ReqwestError(::reqwest::Error);
28        SerdeJsonError(serde_json::Error);
29        EOSIOKeysError(eosio_client_keys::errors::Error);
30        IOError(std::io::Error);
31        UTF8Error(std::string::FromUtf8Error);
32        LibABIEOS(libabieos_sys::errors::Error);
33        Base64(base64::DecodeError);
34    }
35    errors {
36        InvalidResponseContentType{
37            description("expected a content type of application/json")
38            display("invalid content type")
39        }
40        InvalidResponseStatus(err:ErrorInt) {
41            description("EOSIO API error")
42            display("EOSIO API returned {}-{}({}) {:#?}", err.code, err.name,err.what,err.details)
43        }
44
45
46        InvalidResponseErr(err:String) {
47            description("EOSIO API error")
48            display("EOSIO API returned {}", err)
49        }
50        InvalidWASMFormat {
51            description("WASM file has incorrect header")
52            display("Invalid WASM file format")
53        }
54        InvalidABINameLength {
55            description("ABI Names should be max 13 characters long")
56            display("ABI Names should be max 13 characters long")
57        }
58        WalletMissingChainID {
59            description("Wallet needs a Chain ID to sign transactions")
60            display("Missing chain ID in wallet")
61        }
62    }
63}