1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use thiserror::Error;

/// The contract error type
#[derive(Error, Debug)]
pub enum ContractDefError {
	#[error("Contract JSON invalid: `{0}`")]
	InvalidJson(serde_json::Error),
	#[error("ABI parsing error: `{0}`")]
	ABI(ethabi::Error),
	#[error("Contract with identifier not found")]
	SpecNotFound,
	#[error("`{0}`")]
	Other(&'static str),
}

impl From<serde_json::Error> for ContractDefError {
	fn from(e: serde_json::Error) -> Self {
		Self::InvalidJson(e)
	}
}

impl From<ethabi::Error> for ContractDefError {
	fn from(e: ethabi::Error) -> Self {
		Self::ABI(e)
	}
}