pink_web3/contract/
error.rs1use crate::prelude::*;
3
4use crate::error::Error as ApiError;
5use derive_more::{Display, From};
6use ethabi::Error as EthError;
7
8#[derive(Debug, Display, From)]
10pub enum Error {
11 #[display(fmt = "Invalid output type: {}", _0)]
13 InvalidOutputType(String),
14 #[display(fmt = "Abi error: {:?}", _0)]
16 Abi(EthError),
17 #[display(fmt = "Api error: {}", _0)]
19 Api(ApiError),
20 #[display(fmt = "Deployment error: {}", _0)]
22 Deployment(crate::contract::deploy::Error),
23 #[display(fmt = "Deployment error: {}", _0)]
25 #[from(ignore)]
26 JsonDecode(String),
27 InterfaceUnsupported,
29}
30
31#[cfg(feature = "std")]
32impl std::error::Error for Error {
33 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
34 match *self {
35 Error::InvalidOutputType(_) => None,
36 Error::Abi(ref e) => Some(e),
37 Error::Api(ref e) => Some(e),
38 Error::Deployment(ref e) => Some(e),
39 Error::InterfaceUnsupported => None,
40 Error::JsonDecode(_) => None,
41 }
42 }
43}
44
45pub mod deploy {
46 use crate::{error::Error as ApiError, types::H256};
47 use derive_more::{Display, From};
48
49 #[derive(Debug, Display, From)]
51 pub enum Error {
52 #[display(fmt = "Abi error: {:?}", _0)]
54 Abi(ethabi::Error),
55 #[display(fmt = "Api error: {}", _0)]
57 Api(ApiError),
58 #[display(fmt = "Failure during deployment.Tx hash: {:?}", _0)]
60 ContractDeploymentFailure(H256),
61 }
62
63 #[cfg(feature = "std")]
64 impl std::error::Error for Error {
65 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
66 match *self {
67 Error::Abi(ref e) => Some(e),
68 Error::Api(ref e) => Some(e),
69 Error::ContractDeploymentFailure(_) => None,
70 }
71 }
72 }
73}