use thiserror::Error;
#[derive(Debug, Error)]
pub enum ContractRuntimeError {
#[error("hex decode failed: {0}")]
HexDecode(#[from] hex::FromHexError),
#[error("deserialize failed ({context}): {source}")]
Deserialize {
context: &'static str,
#[source]
source: std::io::Error,
},
#[error("serialize failed ({context}): {source}")]
Serialize {
context: &'static str,
#[source]
source: std::io::Error,
},
#[error("contract action address {got} does not match expected {expected}")]
AddressMismatch { expected: String, got: String },
#[error("no contract deployed at address {0}")]
NotFound(String),
#[error("assert failed: {0}")]
AssertionFailed(String),
#[error("circuit execution failed: {0}")]
CircuitExecution(String),
#[error("provider error ({provider}): {message}")]
Provider {
provider: &'static str,
message: String,
},
#[error("i/o error ({context}): {source}")]
Io {
context: &'static str,
#[source]
source: std::io::Error,
},
#[error("well-formedness check failed: {0}")]
WellFormed(String),
}
pub type Result<T> = std::result::Result<T, ContractRuntimeError>;